David Daudelin
David Daudelin

Reputation: 611

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?

Upvotes: 11

Views: 22723

Answers (4)

nicolsondsouza
nicolsondsouza

Reputation: 426

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.

Upvotes: 0

Mark Foreman
Mark Foreman

Reputation: 2480

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)

Upvotes: 0

Santhosh Gutta
Santhosh Gutta

Reputation: 346

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

Upvotes: 7

pherris
pherris

Reputation: 17703

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.

Upvotes: 20

Related Questions