Why is PhoneGap/Cordova not adding android platform? - android

So I've been trying for a few days to add the android platform to my project but I keep getting this response in terminal. (Using OSX, Phonegap 3.3.0)
Creating android project...
/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/XerxesNoble/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:126
throw e;
^
Error: The command "android" failed. Make sure you have the latest Android SDK installed, and the "android" command (inside the tools/ folder) is added to your path.
at /Users/XerxesNoble/.cordova/lib/android/cordova/3.3.0/bin/lib/check_reqs.js:85:29
at _rejected (/Users/XerxesNoble/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:808:24)
at /Users/XerxesNoble/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:834:30
at Promise.when (/Users/XerxesNoble/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/Users/XerxesNoble/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:752:41)
at /Users/XerxesNoble/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:574:44
at flush (/Users/XerxesNoble/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
at /usr/local/lib/node_modules/cordova/src/platform.js:244:30
at ChildProcess.exithandler (child_process.js:641:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:735:16)
at Socket.<anonymous> (child_process.js:948:11)
at Socket.EventEmitter.emit (events.js:95:17)
at Pipe.close (net.js:466:12)
I've made sure to install the SDK from developer.android and I have set my .bash-profile $PATH to:
export PATH=${PATH}:Android/sdk/platform-tools:Android/sdk/tools
At this point I'm really not sure what else I can do to trouble shoot the problem.
Any help would be much appreciated!

This error because Android is not defined to your machine, this means that your paths are not right, so all you have to do is to update bash profile file with corresponding paths.
I think that PATH=${PATH}:Android/sdk/platform-tools:Android/sdk/tools is not right, it should be absolute path to these folders.
something like:
export PATH=/Users/your_user/adt-bundle-mac-x86_64-20130522/sdk/tools/:/Users/your_user/adt-bundle-mac-x86_64-20130522/sdk/platform-tools/:$PATH

Related

getting error, while adding android platform for phonegap

Today I started phonegap, as per documentation I am trying to setup my environment into my local machine.
In this process, I installed android SDK and set the environment variables in bashrc file.
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export JAVA_HOME
PATH=$PATH:$JAVA_HOME
ANDROID_HOME=$HOME/Git/adt-bundle-linux/sdk
export ANDROID_HOME
PATH=$PATH:$ANDROID_HOME
ANDROID_PLATFORM_TOOLS=$ANDROID_HOME/platform-tools
export ANDROID_PLATFORM_TOOLS
PATH=$PATH:$ANDROID_PLATFORM_TOOLS
ANDROID_TOOLS=$ANDROID_HOME/tools
export ANDROID_TOOLS
PATH=$PATH:$ANDROID_TOOLS
export PATH
ANT_HOME=/usr/share/ant
export ANT_HOME
PATH=$PATH:$ANT_HOME/bin
I switch to my working director and getting the following error after ran the cordova platform add android
Creating android project...
/home/.cordova/lib/npm_cache/cordova-
android/3.6.3/package/bin/node_modules/q/q.js:126
throw e;
^
Error: Failed to run "javac -version", make sure you have a Java JDK (not just a JRE) installed.
at /home/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/lib/check_reqs.js:43:27
at ChildProcess.exithandler (child_process.js:651:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:753:16)
at Process.ChildProcess._handle.onexit (child_process.js:820:5)
Error: /home/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/create: Command failed with exit code 8
at ChildProcess.whenDone (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:753:16)
at Process.ChildProcess._handle.onexit (child_process.js:820:5)
#barrett:~/Git/phonegap/hellowPhonegap$
same command ran with "sudo" like sudo cordova platform add android, throwing the following error.
/home/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:126
throw e;
^
Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.
at /home/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/lib/check_reqs.js:158:19
at _fulfilled (/home/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:798:54)
at self.promiseDispatch.done (/home/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:827:30)
at Promise.promise.promiseDispatch (/home/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:760:13)
at /home/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:821:14
at flush (/home/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:419:13)
at Function.Module.runMain (module.js:499:11)
at startup (node.js:119:16)
at node.js:906:3
Error: /home/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/create: Command failed with exit code 8
at ChildProcess.whenDone (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:753:16)
at Process.ChildProcess._handle.onexit (child_process.js:820:5)
Which command shall I use later. If one of it,what's the problem.
can anyone help me.
I face the same problem let's do this javac -version then it show the available versions like
The program 'javac' can be found in the following packages:
* default-jdk
* ecj
* gcj-4.8-jdk
* openjdk-7-jdk
* gcj-4.6-jdk
* openjdk-6-jdk
Try: sudo apt-get install <selected package>
fallow that.
I hope this is helps you.
i had same problem
add this to your path. in windows i did like this path=%path%;%android_home%/platform-tools
Add the path to ANDROID_HOME like this
export ANDROID_HOME='your path'
after check the path like echo $ANDROID_HOME
What happened to me was, that I had the openjre installed, but javac is actually part of the openjdk. Hope this helps someone.

Cordova Platform add android issues

I'm trying to add the android platform however this is the error message I keep getting
C:\Users\Xavier\Desktop\Mtek_DM\Mtek>cordova -d platform add android
cordova library for "android" already exists. No need to download.
Continuing. Checking if platform "android" passes minimum
requirements... Creating android project... Running command:
C:\Users\Xavier.cordova\lib\android\cordova\3.5.1\bin\create.b at
--cli C:\Users\Xavier\Desktop\Mtek_DM\Mtek\platforms\android org.xtek.Mtek Mt ek
C:\Users\Xavier.cordova\lib\android\cordova\3.5.1\bin\node_modules\q\q.js:126
throw e;
^ Error: An error occurred while listing Android targets
at C:\Users\Xavier.cordova\lib\android\cordova\3.5.1\bin\lib\check_reqs.js:
87:29
at _rejected (C:\Users\Xavier.cordova\lib\android\cordova\3.5.1\bin\node_mo
dules\q\q.js:808:24)
at C:\Users\Xavier.cordova\lib\android\cordova\3.5.1\bin\node_modules\q\q.j
s:834:30
at Promise.when (C:\Users\Xavier.cordova\lib\android\cordova\3.5.1\bin\node
_modules\q\q.js:1079:31)
at Promise.promise.promiseDispatch (C:\Users\Xavier.cordova\lib\android\cor
dova\3.5.1\bin\node_modules\q\q.js:752:41)
at C:\Users\Xavier.cordova\lib\android\cordova\3.5.1\bin\node_modules\q\q.j
s:574:44
at flush (C:\Users\Xavier.cordova\lib\android\cordova\3.5.1\bin\node_module
s\q\q.js:108:17)
at process._tickCallback (node.js:415:13) Command finished with error code 8: C:\Users\Xavier.cordova\lib\android\cordova
\3.5.1\bin\create.bat
--cli,C:\Users\Xavier\Desktop\Mtek_DM\Mtek\platforms\andro id,org.xtek.Mtek,Mtek Error:
C:\Users\Xavier.cordova\lib\android\cordova\3.5.1\bin\create.bat:
Comman d failed with exit code 8
at ChildProcess.whenDone (C:\Users\Xavier\AppData\Roaming\npm\node_modules\c
ordova\node_modules\cordova-lib\src\cordova\superspawn.js:135:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)
Furthermore, I created my System environments at
ANDROID_HOME =C:\Users\Xavier\Desktop\Android\sdk\platform-tools
ANT_HOME = C:\Users\Xavier\Desktop\Android\apache_ant1.9.4 JAVA_HOME =
C:\Program Files\Java\jdk1.7.0_21
And linked them under my variable PATH as
C:\Users\Xavier\AppData\Roaming\npm;%ANT_HOME%/bin;%ANDROID_HOME%/tools;%ANDROID_HOME%/platform-tools;%JAVA_HOME%/bin
Am I missing something? because when I typein java in the command line it works but for ant i get "buildfile: build.xml does not exist! build fail"
ANDROID_HOME should point to \sdk, not \sdk\platform-tools\. This is because the build system uses things in both platform-tools and tools folders. Change that and try again in a new terminal window please.

An error occurred while listing Android targets when installing cordova 3.5.0 on Windows 7

with the help of the phonegap docs( http://cordova.apache.org/docs/en/3.5.0//guide_cli_index.md.html), i installed node.js, git client and cordova 3.5.0 successfully.
And also i am able to install windows8 and wp8.
But when installing android, i am getting the following error:
C:\Users\rajkiranb\hello>cordova platform add android
Creating android project...
C:\Users\rajkiranb\.cordova\lib\android\cordova\3.5.0\bin\node_modules\q\q.js:12
6
throw e;
^
Error: An error occurred while listing Android targets
at C:\Users\rajkiranb\.cordova\lib\android\cordova\3.5.0\bin\lib\check_reqs.
js:87:29
at _rejected (C:\Users\rajkiranb\.cordova\lib\android\cordova\3.5.0\bin\node
_modules\q\q.js:808:24)
at C:\Users\rajkiranb\.cordova\lib\android\cordova\3.5.0\bin\node_modules\q\
q.js:834:30
at Promise.when (C:\Users\rajkiranb\.cordova\lib\android\cordova\3.5.0\bin\n
ode_modules\q\q.js:1079:31)
at Promise.promise.promiseDispatch (C:\Users\rajkiranb\.cordova\lib\android\
cordova\3.5.0\bin\node_modules\q\q.js:752:41)
at C:\Users\rajkiranb\.cordova\lib\android\cordova\3.5.0\bin\node_modules\q\
q.js:574:44
at flush (C:\Users\rajkiranb\.cordova\lib\android\cordova\3.5.0\bin\node_mod
ules\q\q.js:108:17)
at process._tickCallback (node.js:419:13)
Error: C:\Users\rajkiranb\.cordova\lib\android\cordova\3.5.0\bin\create.bat: Com
mand failed with exit code 8
at ChildProcess.whenDone (C:\Users\rajkiranb\AppData\Roaming\npm\node_module
s\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:135:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:756:16)
at Process.ChildProcess._handle.onexit (child_process.js:823:5)
In Computer -> C -> Environment variables..
In user variables and system variables, i added ANT.
ANT_HOME = C:\Program Files (x86)\WinAnt
But no luck.
Please help me out.
Add this directly to your path varible
C:\Users\rajkiranb\android\adt-bundle-windows-x86_64-20140321\sdk\platform-tools‌​;C:\Users\rajkiranb\android\adt-bundle-windows-x86_64-20140321\sdk\tools
See the second one is tools not build-tools
Check whether you have ANDROID_HOME system variable set to android sdk location

Error while adding android platform for cordova

D:\Shabbir\AndroidTest>cordova platform add android
Creating android project...
C:\Documents and Settings\avaya11\Application Data\npm\node_modules\cordova\node
_modules\q\q.js:126
throw e;
^
Error: An error occured during creation of android sub-project.
C:\Documents and Settings\avaya11\.cordova\lib\android\cordova\3.3.0\bin\node_mo
dules\q\q.js:126
throw e;
^
Error: An error occurred while listing Android targets
at C:\Documents and Settings\avaya11\.cordova\lib\android\cordova\3.3.0\bin\
lib\check_reqs.js:87:29
at _rejected (C:\Documents and Settings\avaya11\.cordova\lib\android\cordova
\3.3.0\bin\node_modules\q\q.js:808:24)
at C:\Documents and Settings\avaya11\.cordova\lib\android\cordova\3.3.0\bin\
node_modules\q\q.js:834:30
at Promise.when (C:\Documents and Settings\avaya11\.cordova\lib\android\cord
ova\3.3.0\bin\node_modules\q\q.js:1079:31)
at Promise.promise.promiseDispatch (C:\Documents and Settings\avaya11\.cordo
va\lib\android\cordova\3.3.0\bin\node_modules\q\q.js:752:41)
at C:\Documents and Settings\avaya11\.cordova\lib\android\cordova\3.3.0\bin\
node_modules\q\q.js:574:44
at flush (C:\Documents and Settings\avaya11\.cordova\lib\android\cordova\3.3
.0\bin\node_modules\q\q.js:108:17)
at process._tickCallback (node.js:415:13)
at C:\Documents and Settings\avaya11\Application Data\npm\node_modules\cordo
va\src\platform.js:244:30
at ChildProcess.exithandler (child_process.js:641:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)
D:\Shabbir\AndroidTest>
This Error I got
I downloaded NodeJS and install Following
npm -g install phonegap
npm -g install cordova
npm -g install plugman
npm -g install ant
I set some path for that
PATH
C:\Documents and Settings\avaya11\Application Data\npm;C:\Documents and Settings\avaya11\Application Data\npm\node_modules\ant;C:\NEW ANDROID\sdk\platforms;C:\NEW ANDROID\sdk\platform-tools;C:\Documents and Settings\avaya11\Application Data\npm\node_modules\ant\bin;C:\Program Files\Java\jdk1.6.0_45\bin
this is ANT_HOME path that i downloaded from here
ANT_HOME
C:\Program Files\Java\apache-ant-1.9.3
also added JAVA_HOME , ANDROID_HOME
I did all possible ways but still found error PLZ help me to find solution
I think I confused to set a path.
After so much research work I found the answer.
I have not set path of the xcopy.
xcopy.exe - this file contains sdk platform information. So I added path of this. xcopy.exe is located in system32 folder.
So I added path like this and I able to add android platform.
%SystemRoot%\System32;
this path issues
Click on the Start menu in the lower-left corner of the desktop, right-click on Computer, then click Properties.
Click Advanced System Settings in the column on the left.
In the resulting dialog box, press Environment Variables.
Select the PATH variable and press Edit.
Append the following to the PATH based on where you installed the SDK, for example
C:\Development\adt-bundle\sdk\platform-tools;C:\Development\adt-bundle\sdk\tools
refer
here for windows

Can't add android platform in cordova 3.3

I tried to add the android platform by:
$ cordova platform add android
I get that out:
Creating android project...
/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/jannisportmann/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:126
throw e;
^
Error: The command "android" failed. Make sure you have the latest Android SDK installed, and the "android" command (inside the tools/ folder) is added to your path.
at /Users/jannisportmann/.cordova/lib/android/cordova/3.3.0/bin/lib/check_reqs.js:85:29
at _rejected (/Users/jannisportmann/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:808:24)
at /Users/jannisportmann/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:834:30
at Promise.when (/Users/jannisportmann/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/Users/jannisportmann/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:752:41)
at /Users/jannisportmann/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:574:44
at flush (/Users/jannisportmann/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
at /usr/local/lib/node_modules/cordova/src/platform.js:244:30
at ChildProcess.exithandler (child_process.js:641:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:735:16)
at Socket.<anonymous> (child_process.js:948:11)
at Socket.EventEmitter.emit (events.js:95:17)
at Pipe.close (net.js:466:12)
I specified the SDK's path in the .bash_profile, is there something more I need to do?
Thanks for answers!
I fixed it!! First you have to add android tools and platform tools to your PATH...
So open your user profile ( in terminal type:)
nano ~/.profile
PATH=$PATH:/YOUR_ADT_FOLDER/sdk/platform-tools:/YOUR_ADT_FOLDER/sdk/tools
export PATH
Save it and type on terminal:
. ~/.profile
Now try to add your cordova platform, if it not works try to install apache ant. I'm using elementary os, so I opened the software center, searched for ant e install it. After it see if 'ant' is on your terminal and then add your platform.
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
check your path with echo $PATH (use caps, it's case sensitive!)
this is documentation Phonegab docs for setup .bash_profile(mac),bashrc(linux), or windows
and my .bash_profile:
export PATH=${PATH}:$HOME/Development/adt-bundle-mac-x86_64-20140321/sdk/platform-tools:$HOME/Development/adt-bundle-mac-x86_64-20140321/sdk/tools
visit the solution here
I hope this helps you
Try,
cordova platform add android

Categories

Resources