Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PhoneGap 3.0 Android build Command failed to execute : ant jar

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?

like image 877
David Daudelin Avatar asked Oct 21 '13 01:10

David Daudelin


2 Answers

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.

like image 97
pherris Avatar answered Nov 09 '22 07:11

pherris


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

like image 28
Santhosh Gutta Avatar answered Nov 09 '22 07:11

Santhosh Gutta