8

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

5
  • are your running it as root ? probably you can type echo $ANDROID_HOME you'll get back an empty string
    – Blackbelt
    Oct 6, 2014 at 12:24
  • no i am running as normal user only
    – Dev
    Oct 7, 2014 at 4:37
  • system@system-H81M-S1:~$ echo $ANDROID_HOME /home/system/adt-bundle-linux-x86_64-20140702/sdk/tools
    – Dev
    Oct 7, 2014 at 5:15
  • system@system-H81M-S1:/usr/share/nginx/www/myApp# to me it odes look ad you are running it as root
    – Blackbelt
    Oct 7, 2014 at 5:55
  • @blackbelt Hi i am working in non root user only .. even i configured the same for non root user. I also tried in root user but anyway its not working ... Any suggestion like where this error occurring ? in general why this error occurs ?
    – Dev
    Oct 7, 2014 at 8:32

5 Answers 5

13

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
13

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...

1
  • Strangely enough, after doing this I also had to 'export ANDROID_HOME="/home/android-sdk' ... at least it's working now! Hours later... Dec 8, 2016 at 18:48
0

I had the same problem but I found an alternative method i.e. using the Phonegap Developer App. You could install it to the emulator and use it.

0

In my case I first created the ionic app and ran other ionic commands using SUDO; that's why it was not working as sudo uses root profile.

This is how i fixed:

  1. delete the /home/user1/.cordova (replace user1 with you user name) i used "sudo rm" command to delete folder and all of its conents

  2. i deleted the /home/user1/tmp folder so that when we run the cordova again it creates the new tmp folder with proper permission of current user

  3. created new app using "ionic start app5" - this was the main issue as i previously was doing it with sudo

  4. added platform using "ionic platform add android"

  5. executed using "ionic run android"

remember that if from command line you can run "android" command and "java -version" command then above is perfect solution. let me know if you guys need any help from me.

1
  • if you can not run android and java commands let me know i will help you fix that Jul 22, 2015 at 17:56
-1

After facing for many day with this issue i follow the instructions above and set my .bash_profile like this on MAC

#====================================================
export ANT_HOME=/usr/local/Cellar/ant/1.9.4/bin/ant
#
export HOME="/Users/User"
export ANDROID_HOME="$HOME/Downloads/Developer/adt-bundle-mac-x86_64-20140702/sdk"
export PATH="$HOME/Downloads/Developer/adt-bundle-mac-x86_64-20140702/sdk/tools:$ANDROID_HOME/platform_tools:$PATH"
#
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=${PATH}
#
export PATH=${PATH}:/Users/User/Downloads/Developer/adt-bundle-mac-x86_64-20140702/sdk/platform-tools:/Users/User/Downloads/Developer/adt-bundle-mac-x86_64-20140702/sdk/tools:/Users/User/Downloads/Developer/adt-bundle-mac-x86_64-20140702/sdk/build-tools/android-4.4W
#
NPM_PACKAGES="${HOME}/.npm-packages"
PATH="$NPM_PACKAGES/bin:$PATH"
NODE_PATH="$NPM_PACKAGES/lib/node_modules:$NODE_PATH"
#
# Unset manpath so we can inherit from /etc/manpath via the manpath
# command
unset MANPATH # delete if you already modified MANPATH elsewhere in your config
MANPATH="$NPM_PACKAGES/share/man:$(manpath)"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.