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.
Related
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 ...
I am new to phonegap the tutorials I have referred to says that there should be a cordova.jar file inside the phonegap-2.9.1\lib\android path. But I don't have it in this phonegap 2.9.1 version.
Can I download the cordova.jar from anywhere or is there any alternative?
Someone please help me.
Thanks.
First, you need the following requisites, for sure are covered if you have been playing with phonegap/cordova for a while ;)
Java JDK 1.5 or greater
Apache ANT 1.8.0 or greater
Android SDK http://developer.android.com
And then, to generate the cordova-2.9.1.jar file, follow the next steps:
Download and extract the phonegap-2.9.1.zip file.
In a terminal/cmd window go inside the recently extracted directory:
$ cd phonegap-2.9.1\lib\android\framework\
Execute the following commands (you need android sdk and ant already configured in your system path):
$ android update project -p . -t android-17
If required add the --subprojects parameter:
$ android update project -p . -t android-17 --subprojects
You get a message like this:
Updated project.properties
Updated local.properties
build.xml: Found version-tag: custom. File will not be updated.
Updated file D:\work_NEW\phonegap-2.9.1\lib\android\framework\proguard-project.txt
Updated and renamed default.properties to project.properties
Updated local.properties
No project name specified, using Activity name 'DroidGap'.
If you wish to change it, edit the first line of build.xml.
Added file D:\work_NEW\phonegap-2.9.1\lib\android\framework\bin\build.xml
Added file D:\work_NEW\phonegap-2.9.1\lib\android\framework\bin\proguard-project.txt
Finally run:
$ ant jar
Blablabla....
jar:
[jar] Building jar: xxx\phonegap-2.9.1\lib\android\framework\ cordova-2.9.1.jar
BUILD SUCCESSFUL
Total time: 4 seconds
Done!!!!! The file is ready! And you can find this and other information reading a file inside the phonegap-2.9.1.zip:
phonegap-2.9.1\lib\android\README.md
Since 3.x version phonegap has changed a lot. I suggest you to install 3.3 version and create a proyect following the steps described in the offical page.
Also, you can download cordova from cordova web page, add to path, and create a proyect using terminal:
cordova create app_name
cordova platform add android || cordova build android
In 3.3.0 version, You can get cordova-3.3.0.jar file by following these steps:
Go to Command Prompt:
$ cd %HOMEPATH%/.cordova/lib/android/cordova/3.3.0/framework
$ android update project -p
$ ant jar
After executing these commands you will get cordova-3.3.0.jar in framework folder i.e.
=> %HOMEPATH%/.cordova/lib/android/cordova/3.3.0/framework/cordova-3.3.0.jar
I've read this: Cordova and setting Android using command line
and that How to add android to cordova platform? PATH error? and generally speaking whole documentation. I've added both 'platform-tool' and 'tool' paths, installed android 4.4 and I'm still getting the error from the tittle when I'm trying cordova platform add android to my current project ( in cmd and in netbeans ).
The only thing I haven't done is adding java and ant to path. I was trying with ;%JAVA_HOME%\bin;%ANT_HOME%\bin but still those commands aren't recognizable.
What else can I do?
EDIT:
I've added java and ant to PATH. This is what I get in cmd:
C:\xampp\htdocs\mobile_maps>cordova platform add android
[Error: The command `android` failed. Make sure you have the latest Android SDK
installed, and the `android` command (inside the tools/ folder) added to your pa
th. Output: ]
Second EDIT:
i also get 'xcopy' is not recognized as an internal or external command even though I've added %SystemRoot%\System32; %SystemRoot%; %SystemRoot%\System32\wbem;%SystemRoot%\System32\WindowsPowerShell\v1.0 . I really don't know what else I can do..
usually this happens when:
1. Java is not installed
2. Java is not exported (no JAVA_HOME env variable) or paths are wrong
3. only 64bit version of Java is installed
to fix install 32bit support on your system.
and (as comments below) relog in Windows to environment changes take effect.
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.
I'm trying to follow this OpenCV document to import OpenCV sample projects into the android ADT, and am getting the now infamous "Program "C:\android\android-ndk-r8d-windows\ndk-build" not found in PATH" error. My OS is Windows 7 and I use cygwin for any Linux-like commands.
Please note: I already downloaded the NDK package, and already set the value of NDKROOT to be my NDK root folder. I setup NDKROOT both as a system-wide environmental variable, and as an ADT's C/C++ Build environment variable, as shown below:
In my NDK root folder, I made identical copies of the file "ndk-build.cmd", and renamed them as "ndk-build" and "ndk-build.sh" respectively. I chmod+x to all three ndk-build* files.
Now what happens is really puzzling: If I specify the C/C++ Build command to be ${NDKROOT}/ndk-build or ${NDKROOT}/ndk-build.sh, I get the error "Program "C:\android\android-ndk-r8d-windows\ndk-build" not found in PATH". However, if I specify it to be ${NDKROOT}/ndk-build.cmd, ADT apparently finds it, but tries to run it as a Windows command, not as a bash script, as shown below:
The only way I can build a project, is to open a cygwin terminal, cd to the sample project folder, and run the script (either ndk-build or ndk-build.sh), like this:
I googled around for a solution. Although there are lots of "ndk-build.cmd not found in PATH" questions, I have not seen a case like mine. What is happening? I might also post my question to the openCV forum.
Apparently, the command that your Eclipse tries to run (when using the ${NDKROOT}/ndk-build.cmd version) is C:\\android\\android-ndk-r8d-windows\\ndk-build.cmd, which is apparently correct.
The problem is that your ndk-build.cmd is not a windows command file. And it should be. I just downloaded the Windows version of the ndk-r8e and the ndk-build.cmd file is copied here.
Try to download the ndk again or to modify your cmd file.
you should add the ${NDKROOT} variable (which is the folder in which the NDK is located) the same way you did with the PATH variable