Cómo solucionar este problema de que no has aceptado la licencia , y por ello no te deja generar aplicaciones android por linea de comandos.
Android Build Tools 26.0.2 license agreement not accepted
Checking the license for package Android SDK Build-Tools 26.0.2 in /home/mig/tools/licenses
Warning: License for package Android SDK Build-Tools 26.0.2 not accepted.
Checking the license for package Android SDK Platform 26 in /home/mig/tools/licenses
Warning: License for package Android SDK Platform 26 not accepted.
Failed to notify ProjectEvaluationListener.afterEvaluate(), but primary configuration failure takes precedence.
java.lang.RuntimeException: You have not accepted the license agreements of the following SDK components:
[Android SDK Platform 26, Android SDK Build-Tools 26.0.2].
Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
vamos a la ruta $ANDROID_HOME/tools/bin desde el terminal
cd $ANDROID_HOME/tools/bin
y lanzamos
./sdkmanager --licenses
nos mostrará las licencias y tendremos que ir aceptándolas una a una.
Con esto ya debería estar todo ok, pero si aun tienes el problema de las licencias no aceptadas, entonces es que tienes algun problema con los permisos, para eso dale permisos 777 a tu carpeta en la que tengas el sdk.
sudo chmod -R 777 /tu-carpeta-sdk/