Hi, when I try to start my Ionic App with the ionic cordova run android
or the ionic cordova emulate android
the process fails
I’ve this output in Console:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
aapt2 is missing on 'C:\Users\f.menghini\AppData\Local\Android\sdk\build-tools
\27.0.3\aapt2.exe'
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
21 actionable tasks: 1 executed, 20 up-to-date
(node:7156) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejec
tion id: 1): Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
aapt2 is missing on 'C:\Users\f.menghini\AppData\Local\Android\sdk\build-tools
\27.0.3\aapt2.exe'
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
(node:7156) DeprecationWarning: Unhandled promise rejections are deprecated. In
the future, promise rejections that are not handled will terminate the Node.js p
rocess with a non-zero exit code.
[OK] Your app has been deployed.
Did you know you can live-reload changes from your app with --livereload?
I’ve checked in the specified path and the aapt2.exe doesn’t exist.
Remove all the icon and splash image inside the ./resources/android (broken image may be). Then generate again by running ionic cordova resources and build it again. Run your command ionic cordova run android afterward.
I’ve removed the images as you told me, I’ve generate images again, then I’ve tried to rebuild project with ionic cordova build
but I’ve the same error
Did you install Android? Try to install Android Studio, open a new Project with it and open the SDK Manager from the toolbar (should be 2nd symbol from right) and install Android 8, Android SDK Build Tools, Android SDK Platform-Tools, Android SDK Tools and Support Repository. Also add the Android SDK Location you find in the SDK Manager to your Path variable:
set ANDROID_HOME=C:\<installation location>\android-sdk-windows set PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools
I’ve installed Android Studio and the reccomended packages yet, but now I’ll try to uninstall and reinstall them as you have told me.
I’ll let you know as soon as the operation is over
Now the Android SDK Location is added, in ionic info I have:
…
ANDROID_HOME : C:\Users…\Android\Sdk
…
and it’s the right directory!
But the output of ionic cordova run android is:
...
cordova run android
Android Studio project detected
[11:49:28] lint finished in 5.03 s
ANDROID_HOME=C:\Users\f.menghini\AppData\Local\Android\Sdk
JAVA_HOME=C:\Program Files\java\jdk1.8.0_151
studio
Subproject Path: CordovaLib
Subproject Path: app
(node:6828) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejec
tion id: 1): Error: cmd: Command failed with exit code ENOENT
(node:6828) DeprecationWarning: Unhandled promise rejections are deprecated. In
the future, promise rejections that are not handled will terminate the Node.js p
rocess with a non-zero exit code.
[OK] Your app has been deployed.
Did you know you can live-reload changes from your app with --livereload?
Wow! Okay, lets try something else. The project path, if the project path is long, try to change the project location to a direct/short path
For example: Old path: c:\users\your-user-name\projects-container\folders\project-folder New path: c:\users\your-user-name\project-folder
If I could remember, I once had a similar issue though mine was as a result of changing my project folder name from upper case to lower case (PRojects -> projects).
I’ve tried to change the Project location to a shorter one but it doesn’t work.
I’ve also tried to change name of the Project folder with a new name without any uppercase char, but it doesn’t work.
Gradle doesn’t exist, gradle isnt’ a recognized command from my prompt.
I’ve installed the latest gradle (4.4.1) with Chocolatey.
Now I’ve the same output when I’m trying to run the app:
...
cordova run android
Android Studio project detected
[12:27:55] lint finished in 6.93 s
ANDROID_HOME=C:\Users\f.menghini\AppData\Local\Android\Sdk
JAVA_HOME=C:\Program Files\java\jdk1.8.0_151
studio
Subproject Path: CordovaLib
Subproject Path: app
(node:1680) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: cmd: Command failed with exit code ENOENT
(node:1680) DeprecationWarning: Unhandled promise rejections are deprecated. In
the future, promise rejections that are not handled will terminate the Node.js p
rocess with a non-zero exit code.
[OK] Your app has been deployed.
Did you know you can live-reload changes from your app with --livereload?
------------------------------------------------------------
Gradle 4.4.1
------------------------------------------------------------
Build time: 2017-12-20 15:45:23 UTC
Revision: 10ed9dc355dc39f6307cc98fbd8cea314bdd381c
Groovy: 2.4.12
Ant: Apache Ant(TM) version 1.9.9 compiled on February 2 2017
JVM: 1.8.0_151 (Oracle Corporation 25.151-b12)
OS: Windows 7 6.1 amd64
But when I’m trying to remove android platform I’ve this error:
(node:5988) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejec
tion id: 1): Error: cmd: Command failed with exit code ENOENT
(node:5988) DeprecationWarning: Unhandled promise rejections are deprecated. In
the future, promise rejections that are not handled will terminate the Node.js p
rocess with a non-zero exit code.
I’ve done it, manually remove folder, remove and install nodejs, but the error persists
I can’t add android platform now, so far this command has never given me any kind of problem