I am new in phonegap. I am getting error when I add android in phonegap. I have used this steps to solve this error but I am still getting this error:
/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/ss/.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/ss/.cordova/lib/android/cordova/3.3.0/bin/lib/check_reqs.js:85:29
at _rejected (/Users/ss/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:808:24)
at /Users/ss/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:834:30
at Promise.when (/Users/ss/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/Users/sss/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:752:41)
at /Users/ss/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:574:44
at flush (/Users/ss/.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)
You have to add /pathToAndroidFolder/sdk/platform-tools and /pathToAndroidFolder/sdk/tools to your $PATH
steps for Mac OSX: edit your .bash_profile using nano or any other editor
nano ~/.bash_profile
add this line
export PATH=${PATH}:/Users/ss/Documents/Software/adt-bundle-mac-x86_64-20130729/sdk/tools:/Users/ss/Documents/Software/adt-bundle-mac-x86_64-20130729/sdk/platform-tools
open a new terminal window to make it work, or use this command to make it work on the curren terminal window:
source ~/.bash_profile
There is step-by-step instructions on the PhoneGap Doc'.you can use this to solve the issue link
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!)
Related
I just started Android development with ionic framework on Linux (Ubuntu).
I successfully created my ionic project using the command:
sudo ionic start demo blank
Now to add the android platform to the project, I ran the command:
sudo ionic platform add android
And this is the result it gave me:
function bold() { [native code] } https://github.com/driftyco/ionic-default-resources/archive/master.zip
[=============================] 100% 0.0s
Adding android project...
Creating Cordova project for the Android platform:
Path: platforms/android
Package: com.ionicframework.demo504884
Name: demo
Activity: MainActivity
Android target: android-24
Subproject Path: CordovaLib
Android project created with cordova-android#6.0.0
ls: no such file or directory: /home/awa/Desktop/mobile/demo/res/mipmap-*
Installing "cordova-plugin-console" for android
Failed to install 'cordova-plugin-console':CordovaError: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.
at /home/awa/Desktop/mobile/demo/platforms/android/cordova/lib/check_reqs.js:222:19
at _fulfilled (/home/awa/Desktop/mobile/demo/platforms/android/cordova/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/home/awa/Desktop/mobile/demo/platforms/android/cordova/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/home/awa/Desktop/mobile/demo/platforms/android/cordova/node_modules/q/q.js:796:13)
at /home/awa/Desktop/mobile/demo/platforms/android/cordova/node_modules/q/q.js:857:14
at runSingle (/home/awa/Desktop/mobile/demo/platforms/android/cordova/node_modules/q/q.js:137:13)
at flush (/home/awa/Desktop/mobile/demo/platforms/android/cordova/node_modules/q/q.js:125:13)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.
At first I doubted if it had successfully added the android platform so I ran the same command again (sudo platform add android) and it said platform already existed.
Now seeing the last section of the error, I set the ANDROID_HOME environment variable by putting this code at the end of my .bashrc file located my home directory.
export ANDROID_HOME=/home/awa/Android/Sdk
export PATH=$PATH:/home/awa/Android/Sdk/tools
export PATH=$PATH:/home/awa/Android/Sdk/platform-tools
I saved the file. In order to build my project, I ran the command:
sudo ionic build android
and it gave the error:
add to body class: platform-android
Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.
I verified again to make sure I had succeeded in setting the ANDROID_HOME environment variable correctly. So in the Command line I ran the command echo $ANDROID_HOME and it gave as output:
/home/awa/Android/Sdk
...which is the right directory for my SDK.
I have tried other solutions like setting the environment variables in the .profile file but nothing changed.
Now I am suspecting the problem may have something to do with my sdk version though I'm not entirely sure.
What am I doing wrong, or what I'm I missing?
I'm trying to do my first android app in javascript with [phonegap][1] (cordova).
But when I put "phonegap run android" it exits with error 8, this is the code, here is the pic: http://i.stack.imgur.com/qofsZ.png (can't post screen because of reputation):
giulio#cucina:~/Documenti/web/sveglia/sveglia$ phonegap run android
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] adding the Android platform...
/home/giulio/.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 /home/giulio/.cordova/lib/android/cordova/3.5.1/bin/lib/check_reqs.js:87:29
at _rejected (/home/giulio/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:808:24)
at /home/giulio/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:834:30
at Promise.when (/home/giulio/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/home/giulio/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:752:41)
at /home/giulio/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:574:44
at flush (/home/giulio/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:419:13)
{ [Error: /home/giulio/.cordova/lib/android/cordova/3.5.1/bin/create: Command failed with exit code 8] code: 8 }
[error] /home/giulio/.cordova/lib/android/cordova/3.5.1/bin/create: Command failed with exit code 8
I've tried to follow these instructions: stackoverflow.com/questions/20323787/cordova-platform-add-android-not-working-while-listing-android-targets/21142421#21142421 and stackoverflow.com/questions/24380283/phonegap-run-android-create-command-failed-with-exit-code-8-linux, but again it doesn't work.
This is the bashrc (http://i.stack.imgur.com/mdLDY.png), I've put the code at the top:
export ANDROID_HOME="/media/giulio/Secondo\ Disco/Development/android-sdk-linux/tools"
export ANDROID_PLATFORM_TOOLS="/media/giulio/Secondo\ Disco/Development/android-sdk-linux/platform-tools"
export PATH="$ANDROID_HOME:$ANDROID_PLATFORM_TOOLS:$PATH"
export PATH="$PATH:/usr/share/ant/bin"
~/.bashrc: executed by bash(1) for non-login shells.
...etc
I've already installed android packages, ant and everything necessary.
You're my last chance! D:
Export the two variables:
ANDROID_HOME and JAVA_HOME
And, in addition, put android platform-tools on the PATH, works for me.
In my case, it was something like this:
export ANDROID_HOME=/home/YOURUSER/sw/android/adt-bundle-linux-x86-20131030/sdk/
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386/
export PATH="/home/YOURUSER/sw/android/adt-bundle-linux-x86-20131030/sdk/platform-tools/:/home/YOURUSER/sw/android/adt-bundle-linux-x86-20131030/sdk/tools:tools:$PATH"
I am trying to create a phonegap app, but each time I try to add a platform I get this error:
Creating a new cordova project with name "HelloWorld" and id "com.mc2now.hello" at location "/Users/tony/Desktop/eclipse/eclipse"
imac-6:eclipse tony$ cd eclipse
imac-6:eclipse tony$ cordova platform add android
Creating android project...
/Users/tony/.cordova/lib/android/cordova/3.4.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/tony/.cordova/lib/android/cordova/3.4.0/bin/lib/check_reqs.js:85:29
at _rejected (/Users/tony/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:808:24)
at /Users/tony/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:834:30
at Promise.when (/Users/tony/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/Users/tony/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:752:41)
at /Users/tony/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:574:44
at flush (/Users/tony/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
Error: /Users/tony/.cordova/lib/android/cordova/3.4.0/bin/create: Command failed with exit code 8
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/src/superspawn.js:112: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)
so, my question is how to add android to my path? I have tried this:
imac-6:eclipse tony$ export PATH=${PATH}:adt-bundle/sdk/platform-tools:/adt-bundle/sdk/tools
can someone please explain what I am doing wrong? Any help is much appreciated!
I had the same problem and it appeared to be permission problems in the installed adt-bundle.
the following fixed it for me:
$ sudo chown -R $(whoami) /Development/adt-bundle
Try going to your user directory cd ~/ and edit .bash_profile then add export PATH=${PATH}:adt-bundle/sdk/platform-tools:/adt-bundle/sdk/tools to that file.
Save, close the terminal and start it up again.
I had the same error on my linux box.
I fixed putting android sdk "tools" subdir in my system PATH env variable.
For example:
export PATH="/opt/android/adt-bundle-linux-x86_64-20140321/sdk/tools:$PATH"
You should also include "platform-tools" subdir.
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
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