Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cordova add platform - Error executing command 'ant'

In the beginning..

I know that this question has been asked way too many times and.. I checked all ansers on SO. Tried every combination and every solution I found but nothing has worked for me so far.


The problem

I've succesfully installed cordova downloading it from the official site and I've been following the Guide.

I've added wp8 platform succesfully first. Then I tried to add android as well.

After executing the command cordova platform add android, I got the following error.

Error: executing command 'ant', make sure you have ant installed and added to your path.

Here's a screenshot with more details:

Error: executing command 'ant', make sure you have ant installed and added to your path.


My efforts

I've installed ANT, the last Java JDK and added all necessary Enviroment Variables to my System.

ANT and JAVA both gets executed fine from any source path.

ant -version outputs

Apache Ant(TM) version 1.9.4 compiled on April 29 2014

java -version outputs

Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)


Enviroment Variables

I've set up every necessary variable. From ANT_HOME to PATH. Everything is as it should be

ANT_HOME: C:\Program Files\Ant 

JAVA_HOME: C:\Program Files\Java\jdk1.8.0_05

ANDROID_HOME: C:\Users\Kevin\Desktop\Cellulare\Development\sdk

PATH: %JAVA_HOME%\bin;%ANT_HOME%\bin;%ANDROID_HOME%\platform-tools;%ANDROID_HOME%\tools; 

As everyone can see, I've also added android platform-tools and tools to my PATH. Same thing for Ant and Java (\bin dirs).

Needless to say but every path is correct.


Having this things said, Why this still doesn't work? I've also restarted my PC as well but with no results.


Solution

Thanks to Kerri Shotts.

My problems were from those spaces in my paths.

So I changed C:\Program Files\... to C:\Progra~1\....

IMPORTANT!

I also noticed there were 2 characters in my strings. Like this ..\C□□ellulare\... They probably came from a wrong copy-paste format. After fixing these things everything worked!

like image 661
Kevin Cittadini Avatar asked May 18 '14 11:05

Kevin Cittadini


1 Answers

Due to the nature of languages, whitespaces are executed in some whilst ignored in others. Utilizing a file name such as "Program(whitespace)Files" does produce errors when compiling from \bin directories. Next time you declare an environmental variable, be sure that your folder does not contain any whitespaces or gaps between the various names. FYI: camelCase scripts where introduced tow work around this concept. Thanks.

like image 59
NexusInk Avatar answered Oct 01 '22 19:10

NexusInk