When calling cordova platform add android in the Windows 8 cmd, the error message ERROR : executing command 'ant', make sure you have ant installed and added to your path is thrown. I have looked through quite a few other StackOverflow posts related to this problem, but continue to receive the same error message. I have installed node.js and GIT as specified in the documentation here: http://cordova.apache.org/docs/en/3.5.0//guide_cli_index.md.html#The%20Command-Line%20Interface. I have also installed ant and added ant, Android tools, and Android platform tools to the user PATH system variable. Here is the current PATH variable:
%ANT_HOME%\bin;%JAVA_HOME%\bin;C:\apache-ant-1.9.4\bin;C:\apache-ant.1.9.4;%ANDROID_HOME%;C:\Users\t-alboul\Desktop\adt-bundle-windows-x86_64-20140702\sdk\tools;C:\Users\t-alboul\Desktop\adt-bundle-windows-x86_64-20140702\sdk\platform-tools;C:\Users\t-alboul\Desktop\adt-bundle-windows-x86_64-20140702\sdk\tools\ant;C:\Users\t-alboul\AppData\Roaming\npm
ANT_HOME: C:\apache-ant-1.9.4
JAVA_HOME: C:\Progra~1\Java\jdk1.8.0_05
ANDROID_HOME: C:\Users\t-alboul\Desktop\Eclipse\adt-bundle-windows-x86_64-20140702\sdk
What else could I try to solve this problem? Is there anything else that I should add to the PATH variable?
Try installing ant with npm instead
npm install -g ant
and add C:\Users\ (your user name)\AppData\Roaming\npm\node_modules\ant\ant\bin to the PATH
I see in your path you have
C:\apache-ant-1.9.4\bin
C:\apache-ant.1.9.4 as well as
%ANT_HOME%\bin and %ANT_HOME% is set to C:\apache-ant-1.9.4
So where is actually tour ant package?
C:\apache-ant-1.9.4 or C:\apache-ant.1.9.4 becase in case it's the second, nothing in your path points to the bin folder.
I strongly suggest you clean up your path and make sure your env vars point to the good folders.
What you need in your path for cordova android is
%ANDROID_HOME%\platform-tools;%ANDROID_HOME%\tools;%JAVA_HOME%\bin;%ANT_HOME%\bin
To check if ant is accessible from the path, open a cmd and run ant -version which should display Apache Ant(TM) version 1.9.4 compiled ...
Related
I m cloning a cordova app sourcecode from github. How do I install cordova and add android platform to it and build it in Android Studio?
After cloning the code, I am installing cordova, but cant add platform or anything related to cordova. Is there any tutorial on how to follow the correct steps to make it run in Android Studio? I am very new to Cordova. Thanks!
First of all: follow the GitHub repo's README and look for installation instructions.
To play around with a cordova app, you most definitely need the cordova CLI. If you haven't already, install NodeJS and npm from http://nodejs.org or using your package manager of choice. Then inside a terminal run
npm install -g cordova
(If you are using Linux you probably have to run that command with sudo)
Now you navigate into the cloned github repo and run
cordova platform add android
cordova build android
It will create a directory under ./platforms/android which you can open using Android Studio. Then you can run the app with an emulator or a connected device.
If at any point you receive error messages or you think something is missing, you can run (inside the GitHub cloned repo)
cordova requirements
It will show you if the cordova CLI is missing something. You will have to fix all the errors that come up. Consult the cordova documentation under https://cordova.apache.org/docs/en/latest/guide/cli/#installing-the-cordova-cli in order to do that.
Hope this helped.
Please note I am not a programmer . I am ex Banker and entrepreneur now .I got really frustrated while setting cordova with all those errors for building android apps in windows. Though, I now understand this is the simplest cake, if you know the know-how. I love coding, so I am sharing the whole length of steps . You can figure out what step you are missing.
Step 1. Requirements :
(a)node js ( npm )-- install it
(b) Install cordova by command -->
npm install -g cordova
(c) Install Phone gap by command --> npm
install -g phonegap
(d) Ant apache ( download bin not source ) by visiting
https://ant.apache.org/bindownload.cgi . Keep this in C:/ Program files
(e) JDK version 8 . you can down load previous version by visiting
oracle.com
NOTE : Keep ( ANT ) and JDK in Same Folder i.e extracted (d) and (e) in C:/Program files
Step: 2 Setting Environment Variables
you can visit : Control Panel\System and Security\System--> environment variables You can see two types of windows : User and System
User Environment Variables:
You have to set ANT_HOME and JAVA_HOME
Add new variable :
Variable name :ANT_ HOME
Variable value : C:\Program Files\apache-ant-1.10.3
Variable name :JAVA_ HOME
Variable value :C:\Program Files\Java\jdk1.8.0_172
System Environment Variables: edit path and at the end use ; and paste ant/bin address
PATH :
Variable name :path
Variable value :....C:\composer;C:\Program Files\Git\cmd;C:\Program Files\apache-ant-1.10.3\bin
NOTE : Check ant & java configuration by windows command prompt :
ant -version and java --version . If using git then git --version.
If you error free then proceed further.
Step 3. Create a cordova project
something like this command: cordova create hello com.example.hello HelloWorld
Step 4. create platform android or ios: ensure proper config.xml
**Step 5. now check cordova requirements: This work in app folder only **
Now build your app.
Other errors you get if you miss these:
check ="ANDROID_SUPPORT_VERSION" in config xml.
Add Required Plugin - cordova plugin add -- as you need in config.xml
Cordova requirements: This work in app folder only
Cant find the Ant Version: you have not used ANT_HOME, JAVA_HOME folder name.Ensure ANT_Home and JAVA_HOME only in User folder while the path in System Variable. Never use / " or ' in writing these variables.
"IF YOU DONT REQUIRE ANT AND GIT ---> Dont download it "
Hope this helps beginners and code layman like me.
Answered on: Android Studio project detected
I have installed netbeans 7.4 and like to test cordova. For this i first need to run cordova from command line. I was able to creat the files. I am following http://cordova.apache.org/docs/en/edge/guide_cli_index.md.html#The%20Command-line%20Interface.
But when i try to build from the command line i am getting the error
The command android failed.......make sure.....Android SDK
installed...to your path
I have add this to my enviroment variables as path
C:\Program Files (x86)\Android\android-sdk
Within netbeans creating a cordova project doesn't work am getting the message
Netbeans cannot find cordova or git on your path
Any tips, suggestions
Don’t do that,try this instead
Enviroment variables should be like this:
C:\Program Files (x86)\Android\android-sdk\platform-tools
C:\Program Files (x86)\Android\android-sdk\tools
then restart your cmd .
The second question I think maybe you should config cordova and git in Netbeans.
Copy the location of the Android SDK:
If you have installed Android Studio:
(Ctrl+Alt+S) File->Settings->Appearance&Behavior->System Settings->Android SDK> Android SDK Location
In Windows 10, you have to point to the sdk folder in the AppData:
C:\Users\\AppData\Local\Android\sdk
Sorry if it's a bit late... But for any others with this same issue (I spent hours on this myself), don't forget to install Apache Ant and set the ANT_HOME variable on your system also.
https://ant.apache.org/
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?
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.
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
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)
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.
I'm trying to do phonegap build android and I have this message :
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] adding the Android platform...
[error] An error occured during creation of android sub-project. Path not found
Phonegap is looking for "C:\Documents and Settings\corbg\.cordova\lib\android\cordova\3.0.0\bin\create". There is nothing under the directory "3.0.0". I installed cordova like this npm install -g cordova.
I have the some problem when I run cordova platform add android.
Did I missing something?
In Windows machine you have to delete .cordova directory under
C:\Users\user_name\
I have face the same issue, then i corrected my application path, afterthat it is worked out for me.
If you are using win 7 then add the Android ADK path in
open the mycomputer -> Properties -> Change Settings-> Advanced -> Environment Variable -> User variable for ....-> path
add the Android ADK path here like as following
C:\AndroidDev\adt-bundle-windows-x86-20131030\sdk\tools; C:\AndroidDev\adt-bundle-windows-x86-20131030\sdk\platform-tools
also add JAVA_HOME and ANT_HOME.
- Abdul Jabbar
Did you set your PATH variable? Sometimes this error occurs in Windows when the PATH variable is not set correctly to access "java" and "ant" exes. If you want to test if they are correctly set, you can simply execute both (from any folder in your command line):
> java
or
> ant
and both programs should be found.
It was a problem with my proxy. Cordova create a .cordova directory and try to download something on the internet. The download did not work. Next time, it check if there is a .cordova directory. It don't try to redownload something because the directory exist and it show the error.
I removed the .cordova directory and I solved my problems with proxy. Now, everythings works.
What solved the issue for me was having 2 directories on my PATH, the android platform-tools and tools.
In my pc those folders were at
C:\Program Files (x86)\Android\android-sdk\tools
C:\Program Files (x86)\Android\android-sdk\platform-tools
Also make sure you have the following environment variables
JAVA_HOME (C:\Program Files\Java\jdk1.7.0_51)
ANT_HOME (C:\Program Files\apache\apache-ant-1.9.3)
ANDROID_HOME (C:\Program Files (x86)\Android\android-sdk\platform-tools)
I removed the .cordova folder under my user folder but I'm not quite sure if that helped as well.
These links may help you
An error occured during creation of android sub-project
android' is not recognized as an internal or external command
I had the exact same problem for a different reason. I had an old version of ant (1.7.1). At least version 1.8.2 is needed for the build to work.
its either due to improper installation or no installation of ANT or JAVA. But moreover we need to add Android SDk and prepare Android Targets via SDK manager before going through this.
This is because you haven't installed ANT!
download it from here and install it step by step
https://ant.apache.org/manual/install.html
Then running the last command it will install the dependencies needed.
After executing the command to create a project...
./create <PATH_TO_PROJECT_DIR> <COM_PATH> <PROJECT_NAME>
I get the error message:
An unexpected error occurred: ANDROID_BIN="${ANDROID_BIN:=$( which android )}" exited with 1
Deleting project...
Troubleshooting responses:
(acconrad provided a smart checklist here for solving Cordova errors...)
Did you download the correct version of PhoneGap from the correct LOCATION? It appears as if
there are versions of PhoneGap that do not come packaged with
Cordova-2.x.0.jar, which is necessary to run the script. Download here
to obtain PhoneGap with the correct JAR file.
I have followed the instructions at the official Apache Cordova API Documentation site and downloaded the cordova-android repository from github. The official documentation does not say anything about this jar file and as such I have not executed it.
Did you already create the folder? The documentation claims that you
can use this command as long as the new folder is blank. This is not
true. Make sure the folder does not exist before attempting to create
the project.
Fresh folder path, never created.
Do you have the latest version of Ant? You will need Ant 1.8.0 or
greater to run PhoneGap with Android. Use ant -v to verify your
version.
Ant version 1.8.2, although running the -v flag pops up the following output...
Apache Ant(TM) version 1.8.2 compiled on June 3 2011
Trying the default build file: build.xml
Buildfile: build.xml does not exist!
Build failed
...as if it was trying to build. I assume -v means verbose and ant is trying to build the current director, in which there is no build.xml file, because I'm not building a project with ant, merely finding the version, which is 1.8.2.
Is your .bash_profile/Environment Varibles PATH set properly? The
official documentation has been updated to reflect this, but you will
absolutely need these variables set correctly in order to create the
project.
Both SDK paths have been set & sourced.
Did you update the terminal to reflect your new PATHs? source
.bash_profile or . .bash_profile in your currently open terminal
window so your paths are updated when running the create command.
Haven't restarted but $PATH outputs the correct android-sdk-macosx paths (platform-tools && tools).
Do you have the correct commons-codec? You may receive an accompanying
error referring to a missing commons-codec file, which you can
download here.
No commons-codec accompanying error is being displayed.
The problem was indeed the PATH variables...
/PATH/TO/android-sdk-maxosx/platform-tools
/PATH/TO/android-sdk-maxosx/tools
removed the macosx from the path name.
Correcting these environment variables in ~/.bash_profile solved this problem.
You should modifying the PATH Environment Variable:
For Ubuntu:
$ nano ~/.bashrc
You will now have the Nano text editor enabled on the terminal. Now, at the very top of the file, enter the following:
#AndroidDev PATH
export PATH=${PATH}:~/android-sdk-linux/tools
export PATH=${PATH}:~/android-sdk-linux/platform-tools
https://help.ubuntu.com/community/AndroidSDK
For Mac OS:
look in your home directory for .bash_profile. Create the .bash_profile file if you don't have one.
Look for the PATH environment variable and add the full path to the tools/ directory to the PATH. If you don't see a line setting the PATH, you can add one: export PATH=${PATH}:/tools
https://sites.google.com/site/richgossweiler/home/android-development-notes/installing-the-android-sdk-on-the-mac-os-x
This also happens if the name of the COM_PATH contains an invalid character or does not have 3 namespaces like:
com.example.project
This is probably because of a wrong PATH. You should edit environment variables in ~/.bash_profile.
Refer this Blog post for a detailed explanation.