Reputation: 61
Maybe it can help you on build error with ionic/cordova error with android platform on windows
After install ant/ionic with :
%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools;%ANDROID_HOME%\build-tools
start a new projet : ionic start hello blank ->ok ionic platform add android -> ok ionic build android - Error:
BUILD FAILED
C:\SDK\android-sdk\tools\ant\build.xml:954: The following error occurred while executing this line:
C:\SDK\android-sdk\tools\ant\build.xml:971: null returned: -1073741819
Total time: 2 seconds
D:\PROD\myapp\platforms\android\cordova\node_modules\q\q.js:126
throw e;
^
Error code 1 for command: cmd with args: /s,/c,ant,debug,-f,D:\PROD\myapp\platforms\android\build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
ERROR building one of the platforms: Error: D:\PROD\myapp\platforms\android\cordova\build.bat: Command failed with exit code 8
You may not have the required environment or OS to build this project
Paths are OK and if I start a new cordova projet (not ionic) build is a success.
If I check problem on c:\android-sdk\build.xml and I add
<echo>aapt: ${aapt}</echo>
I can see aapt.exe path is on android-21 (target is android-19)
For me, problem is I have two android sdk : android 19 and android 21. If I use CLI on windows, ionic/cordova choose android-21\aapt.exe by default and no android-19\aapt.exe
I tried to force Path with android version : %ANDROID_HOME%\build-tools\19.0.0 with no success.
To resolve this problem I changed paths to force on aapt executable path to point on android 19: File c:\android-sdk\tools\ant\build.xml :
<aapt executable="C:\android-sdk\build-tools\19.0.0\aapt.exe" ...
</aapt>
This is not the best way, but I have not found another.
Upvotes: 3
Views: 2072
Reputation: 1384
Instruction 1:
After adding your ANDROID_HOME, make sure you do the below:
Restart your System or run source ~/.bash_profile
Remove Android platform from your project ionic cordova platform rm android or ionic platform rm android
Add Android platform ionic cordova platform add android
Then ionic cordova run android or ionic run android
Instruction 2: To set your ANDROID_HOME and JAVA_HOME, follow the below steps:
export ANDROID_HOME=/usr/local/Cellar/android-sdk/24.4.1_1 export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
NOTE: Make sure you have **24.4.1_1 SDK**
Hope this helps.
Upvotes: 1