PhoneGap 3.0 Android build Command failed to execute : ant jar

喜夏-厌秋 提交于 2019-12-09 09:06:44

问题


I installed PhoneGap 3.0 with Node.js and configured all the environment variables so that javac, java, and ant all work but when I do a basic app create and try to build it for Android, I get the following error:

An error occurred during creation of android sub-project. Creating Cordova project for the Android platform: Command failed to execute : ant jar

Any ideas?


回答1:


Make sure you have the Android Build Tools installed for your Android SDK version. In the Android SDK manager under Tools>Android SDK Build-tools you should see that the Build tools for your SDK version are not installed.

Detail on how I uncovered this:


To identify this as the root cause I ran the Cordova command with -d for verbosity:

cordova -d platform add android

The output of this command shows the error:

Running bin/create for platform "android" with command: ""C:\Users\---\.cordova\lib\android\cordova\3.1.0\bin\create"  "C:\Users\---\workspace_android\FleetView\platforms\android" "com.---.fleetview" "Fleet View"" (output to follow)

Running the offending command directly:

"C:\Users\---\.cordova\lib\android\cordova\3.1.0\bin\create"  "C:\Users\---\workspace_android\FleetView\platforms\android" "com.---.fleetview" "Fleet View"

produces this output:

BUILD FAILED
C:\tools\adt-bundle-windows-x86_64-20130219\sdk\tools\ant\build.xml:479: SDK does not have any Build Tools installed.

Total time: 1 second
Command failed to execute : ant jar

I am on Windows 7.




回答2:


This is due to ANT tools could not find tools.jar in JRE lib directory. When I copied tools.jar from JDK lib directory to JRE lib directory, the problem was absolutely solved and the build was successful when I ran the command "cordova -d platform add android". Hope this helps you.

Posted the answer to similar question: Android Platform Guide trouble with adding a platform through the command line




回答3:


A combination of 2 things worked for me:

  • include the JDK in your path (path\to\jdk\bin of course)
  • exclude the JRE from your path (or at least have it come after the JDK)



回答4:


I faced the same issue,
I was having jdk-6 and I updated to jdk-7,
that fixed the issue,
Also I didn't installed ant in the first place,
in your case ant PATH might be missing.
See if that helps.



来源:https://stackoverflow.com/questions/19484898/phonegap-3-0-android-build-command-failed-to-execute-ant-jar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!