也许这可以帮助您解决在Windows系统上使用ionic/cordova构建Android平台时遇到的错误。
在安装了ant/ionic之后:
路径正确,如果我开始一个新的cordova项目(不是ionic),构建成功。
如果我检查c:\android-sdk\build.xml上的问题并添加
我看到aapt.exe的路径在android-21上(目标是android-19)。
对我来说,问题在于我有两个Android SDK:android 19和android 21。如果我在Windows上使用CLI,ionic/cordova会默认选择android-21\aapt.exe,而没有android-19\aapt.exe。
我尝试通过用android版本强制路径:%ANDROID_HOME%\build-tools\19.0.0,但没有成功。
为了解决这个问题,我改变了路径,强制aapt可执行文件的路径指向android 19: 文件c:\android-sdk\tools\ant\build.xml:
在安装了ant/ionic之后:
%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools;%ANDROID_HOME%\build-tools
开始一个新项目:ionic start hello blank -> 确定 添加 Android 平台:ionic platform add android -> 确定 构建 Android 应用程序时出现错误:
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
路径正确,如果我开始一个新的cordova项目(不是ionic),构建成功。
如果我检查c:\android-sdk\build.xml上的问题并添加
<echo>aapt: ${aapt}</echo>
我看到aapt.exe的路径在android-21上(目标是android-19)。
对我来说,问题在于我有两个Android SDK:android 19和android 21。如果我在Windows上使用CLI,ionic/cordova会默认选择android-21\aapt.exe,而没有android-19\aapt.exe。
我尝试通过用android版本强制路径:%ANDROID_HOME%\build-tools\19.0.0,但没有成功。
为了解决这个问题,我改变了路径,强制aapt可执行文件的路径指向android 19: 文件c:\android-sdk\tools\ant\build.xml:
<aapt executable="C:\android-sdk\build-tools\19.0.0\aapt.exe" ...
</aapt>
这不是最好的方式,但我没有找到其他方法。