Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ANDROID_HOME is not set and "android" command not in your PATH Phonegap

i have installed android bundle and i have configured everything in .bashrc file and even when i say android in command line .. i am getting android manager .. but when i say ionic platform add android i am always getting error as "Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions." . i tried many way but issue not fixed .

my platform :

Ubuntu 14.04 64 bit

.bashrc file :

    export HOME="/home/system"
    export ANDROID_HOME="$HOME/adt-bundle-linux-x86_64-20140702/sdk/tools"
    export ANDROID_PLATFORM_TOOLS="$HOME/adt-bundle-linux-x86_64-20140702/sdk/platform-tools"
    export PATH="$ANDROID_HOME:$ANDROID_PLATFORM_TOOLS:$PATH"
    export JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64"
    export ANT_HOME="/usr/share/ant"
    export PATH="$ANT_HOME/bin:$PATH"
    export ANDROID_HOME="/home/system/adt-bundle-linux-x86_64-20140702/sdk/tools"

error while execution :

    system@system-H81M-S1:/usr/share/nginx/www/myApp# ionic platform add android
    npm http GET https://registry.npmjs.org/cordova-android/3.6.3
    npm http 200 https://registry.npmjs.org/cordova-android/3.6.3
    npm http GET https://registry.npmjs.org/cordova-android/-/cordova-android-3.6.3.tgz
    npm http 200 https://registry.npmjs.org/cordova-android/-/cordova-android-3.6.3.tgz
    Creating android project...

    /system/.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 /system/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/lib/check_reqs.js:158:19
    at _fulfilled (/system/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:798:54)
    at self.promiseDispatch.done (/system/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:827:30)
    at Promise.promise.promiseDispatch (/system/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:760:13)
    at /system/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:821:14
    at flush (/system/.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: /system/.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.emit (events.js:98:17)
    at maybeClose (child_process.js:756:16)
    at Process.ChildProcess._handle.onexit (child_process.js:823:5)

may i know how i can fix this error

like image 542
Dev Avatar asked Oct 06 '14 12:10

Dev


People also ask

How can I change SDK path in Android Studio?

Click on Appearance and Behavior option > System Settings options and then click on the Android SDK option to get to see the below screen. Inside this screen, you will get to see your SDK path. You can update your SDK path by clicking on the Edit option.


2 Answers

I faced the same problem, and it's solved.

I think it's issue with the compatibility of the latest cordova with latest android. As well as you've issue with the android home path.

In .bashrc file

export HOME="/home/indranil"
export ANDROID_HOME="$HOME/software/adt-bundle-linux-x86_64-20140702/sdk"
export PATH="$HOME/software/adt-bundle-linux-x86_64-20140702/sdk/tools:$ANDROID_HOME/platform_tools:$PATH"

Try to download the latest android SDK if you're using older version. And download Android 4.4.2(API 19) from your android manager.

You can use the latest cordova (4.0.0) but if the issue is still there then use cordova (3.5.0-0.2.7), but if you want to upgrade or downgrade the cordova, remove the existing one using:-

npm uninstall -g cordova  (If linux use sudo npm uninstall -g cordova)

If you are using linux don't use sudo

commad at the time of installing cordoava, if you get any error, run the following commands

sudo chown -R `whoami` ~/.npm
sudo chown -R `whoami` /usr/local/lib/node_modules
sudo chown -R `whoami` /usr/local

Then install cordova without sudo

npm install -g [email protected]

At the time of creating ionic app and adding android as platform don't use sudo command. Cordova creates a .cordova directory in the home folder at the time of adding platform. Remove that directory before creating the new ionic application.

And after downloading the android(4.4.2), create an android virtual device using the command:

android avd
like image 81
Indranil Mondal Avatar answered Nov 04 '22 09:11

Indranil Mondal


I have been struggling with this also (Ubuntu 14.04) and I remember accepting that just getting the cordova build command to work was too difficult for me :-). I was sure my PATHs were correct (tried root and user etc etc) and tried every solution I could find.

A comment by Stoicuta Alexandru On this page solved it for me. I quote:

If ANDROID_HOME is not set, cordova will search for it in home/android-sdk

So just putting my android sdk in the home-folder and (important) naming it android-sdk did it.

Hope to save some people some time...

like image 26
R_Ice Avatar answered Nov 04 '22 08:11

R_Ice