I,m unable to add android platform support to phonegap/cordova project.
when I run following command on CLI :
cordova platforms add android
it's giving this error :
Error: ERROR : executing command 'ant' , make sure you have ant installed and added to your path
you need to clean up your eclipse
cd to your eclipse directory and run this command
./eclipse -clean
Download and install Homebrew by executing following command in terminal:
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
Install Apache Ant via Homebrew by executing
brew install ant
Build project
cordova build android
Related
I did some googleing but find nothing approriate.
Any help appreciated. Try it with an naked vm to be sure
having no nodejs install or dependency issue.
Christian
sudo apt-get install nodejs
sudo apt-get install nodejs-legacy
sudo npm install -g phonegap
sudo npm install -g cordova
sudo apt-get install ant
chris#mint16 ~/project/dev $ phonegap create my-app
[phonegap] create called with the options /home/chris/project/dev/my-app com.phonegap.helloworld HelloWorld
[phonegap] Customizing default config.xml file
[phonegap] created project at /home/chris/project/dev/my-app
chris#mint16 ~/project/dev $ cd my-app/
chris#mint16 ~/project/dev/my-app $ phonegap run android
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] adding the Android platform...
/home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:126
throw e;
^
Error: An error occurred while listing Android targets
at /home/chris/.cordova/lib/android/cordova/3.5.0/bin/lib/check_reqs.js:87:29
at _rejected (/home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:808:24)
at /home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:834:30
at Promise.when (/home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:752:41)
at /home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:574:44
at flush (/home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
{ [Error: /home/chris/.cordova/lib/android/cordova/3.5.0/bin/create: Command failed with exit code 8] code: 8 }
[error] /home/chris/.cordova/lib/android/cordova/3.5.0/bin/create: Command failed with exit code 8
I've just faced the same issue, the problem was that path to sdk tools was not properly setup:
So try the following:
export PATH=$PATH:/usr/local/adt-bundle/sdk/tools
export PATH=$PATH:/usr/local/adt-bundle/sdk/platform-tools
export PATH=$PATH:/usr/local/adt-bundle/sdk/build-tools
I also hit the same issue, but just adding the various android sdk tools directories to the path as DKMudrechenko suggested above did not help. It turned out that I had not installed ant properly. I had downloaded it from apache.org and just added the ant 'bin' folder to my path, but apparently that wasn't good enough. However, after removing that entry from my path statement and adding ant via brew, I was then able to build the android cordova project successfully using the 'cordova build android' command.
i have been facing this issue on and off only to realise that the build fails for other errors in the code/configuration.
the process you have taken does skip one part where the android platform is added
corodova platforms add android
in the steps given above, you have created a project, traversed into the project directory and then ran the build, to which the phone gap checked the installed sdks by checking ANDROID_HOME and tried to set up the project for android.
you might want to run it in a correct order:
create project
move to the project directory
add platform
build / run.
i hope this helps
This is how I have set path on bash_profile file for my Cordova Project
export PATH=${PATH}:/Users/Work/Android/adt-bundle-mac-x86_64-20130219/sdk/platform-tools:/Users/Work/Android/adt-bundle-mac-x86_64-20130219/sdk/tools
export ANT_HOME=/Users/Work/Android/adt-bundle-mac-x86_64-20130219/eclipse/plugins/org.apache.ant_1.8.3.v20120321-1730
export PATH=$PATH:$ANT_HOME/bin
When I try to run " cordova platform add android ", I got
/usr/local/lib/node_modules/cordova/node_modules/q/q.js:126
throw e;
^
Error: An error occured during creation of android sub-project.
/Users/user1/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:126
throw e;
^
Error: ERROR : executing command 'ant', make sure you have ant installed and added to your path.
Try this one
Install ant using brew.
Download and install Homebrew by executing following command in terminal:
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
Install Apache Ant via Homebrew by executing
brew install ant
Run the PhoneGap build again and it should successfully compile and install your Android app.
Try downloading a standalone version of ANT instead of using the one that comes packaged as an Eclipse plugin. The plugin version might be modified to run with Eclipse or might otherwise have some differences that are causing problems. Additionally, I'd think that a standalone version will be easier to upgrade.
On my machine, I'm running ant 1.8.4 - your plugin seems to be ant 1.8.3, so that might be what's causing the difference.
Today I tried PhoneGap/Cordova with Mac OS X Mavericks. Building for iOS went just fine, but building for Android wasn't without some guesswork.
I installed Android 4.2.2 via the Android SDK Manager (I had to use the older API v17 since it wasn't compatible with a newer one), added the PATH environment variables for the SDK's platform-tools and tools and thought I was ready to take off by running the command:
phonegap run android
Nevertheless, I got the following error:
[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. ERROR : executing command 'ant', make sure you have ant installed and added to your path.
The error message proved to be true as Apache Ant isn't in the path of Mac OS X Mavericks anymore.
Bulletproof solution:
Download and install Homebrew by executing following command in terminal:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Install Apache Ant via Homebrew by executing
brew install ant
Run the PhoneGap build again and it should successfully compile and install your Android app.
You can install ANT through macports or homebrew.
But if you want to do without 3rd party package managers, the problem can simply be fixed by downloading the binary release from the apache ANT web site and adding the binary to your system PATH.
For example, on Mountain Lion, in ~/.bash_profile and ~/.bashrc my path was setup like this:
export ANT_HOME="/usr/share/ant"
export PATH=$PATH:$ANT_HOME/bin
So after uncompressing apache-ant-1.9.2-bin.tar.bz2 I moved the resulting directory to /usr/share/ and renamed it ant.
Simple as that, the issue is fixed.
Note Don't forget to sudo chown -R root:wheel /usr/share/ant
As an alternative to homebrew, you could download and install macports. Once you have macports, you can use:
sudo port install apache-ant
it don't needed port and brew!
because you have android sdk package.
.1 edit your .bash_profile
export ANT_HOME="[your android_sdk_path/eclipse/plugins/org.apache.ant_1.8.3.v201301120609]"
// its only my org.apache.ant version, check your org.apache.ant version
export PATH=$PATH:$ANT_HOME/bin
.2 make ant command that can executed
chmod 770 [your ANT_HOME/bin/ant]
.3 test if you see below message. that's success!
command line execute: ant
Buildfile: build.xml does not exist!
Build failed
I encountered the same issue when trying to use Cordova. Turns out I already had brew, try which brew, but it was outdated. So, I had to update it first:
Update brew: brew update
Install Apache Ant: brew install ant
In my case, I have macport installed already. I simply updated my macport:
sudo port selfupdate
sudo port upgrade outdated
Then install apache-ant:
sudo port install apache-ant
Finally, I add ant to my alias list in my .bash_profile:
alias ant='/opt/local/bin/ant'
Then you are all set.
For OSX your path needs to include /Users/yourusername
their example: /Development/adt-bundle/sdk/platform-tools
needs to be: /Users/yourusername/Development/adt-bundle/sdk/platform-tools
Ok Im using cordova 3.0 CLI:
$ cordova create hello com.example.hello "HelloWorld"
$ cd hello
$ cordova platform add android
PROBLEM:
[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 path. Output: /bin/sh: android: command not found]
Then:
$ export PATH=${PATH}:/Users/Primitivo/Dropbox/mobile/sdks/adt-bundle/sdk/platform-tools:/Users/Primitivo/Dropbox/mobile/sdks/adt-bundle/sdk/tools
Again:
$ cordova platform add android
PROBLEM:
[Error: An error occured during creation of android sub-project. An unexpected error occurred: "$ANDROID_BIN" create project --target $TARGET --path "$PROJECT_PATH" --package $PACKAGE --activity $ACTIVITY >&/dev/null exited with 1
Deleting project...]
Then: I dont know what to do, I have java installed and ant too. Please help!
Are you using Java 6. I had the same issue, I wasn't aware Java 7 won't work with Android and downgrading to most recent Java 6 JDK, fixed it, as I remember.
I have installed Cordova along with Phonegap and installed node.js in my system(ubuntu)
by using following commands:
Install Nodejs http://nodejs.org/
Install Cordova 3.0.x
$ sudo npm install -g cordova
Install Phone Gap 3.0.x
$ sudo npm install -g phonegap
Then i created project using phonegap command:
$ phonegap create hello
Trying to run into my local by using following command:
$ phonegap local run andriod
Now at first i am getting following error:
shoaib#shoaib:~/Documents/hello$ phonegap local run android
[phonegap] adding the Android platform...
[error] An error occured during creation of android sub-project. /home/shoaib/.cordova/lib/android/cordova/3.0.0/bin/create: line 54: jar: command not found
This i solved by running following command:
ls -la /home/shoaib/.cordova/lib/android/cordova/3.0.0/bin
Now when i again run
$ phonegap local run andriod
I am getting below error:
root#shoaib:/home/shoaib/Documents/hello# phonegap local run android
[phonegap] compiling Android...
[error] An error occurred while building the android project. /bin/sh: 1: /home/shoaib/Documents/hello/platforms/android/cordova/build: not found
I am using Android SDK 17
and version as 4.2.2 .
Any solution for this issue?
I had a similar problem. build and run were missing along with a few other files and lib was an empty directory. Downloaded cordova-android from here extracted and copied everything from its /bin/templates/cordova/ to the project (/platforms/android/cordova/). Then I could build and install the app.
Still had to start the emulator, check the running emulator with platforms/android/cordova/lib/list-started-emulators and then pass it when installing or it would take forever to install it on an emulator.
$ platforms/android/cordova/lib/list-started-emulators
emulator-5554
$ phonegap install --emulator=emulator-5554 android
I had already installed the JDK but the same error.
To fix this I just removed the phone test project and make sure that:
Java, javac and jar where in the path
(both should work)
java -version
javac -version
jar -version
Android sdk path was properly set and JAVA_HOME environment variable was properly set.
Then I remake the project and everything worked.
Hey got the solution.
I install open jdk 6.0 and problem is resolved.