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

Hi Guys,
I’m working with OS X Yosemite and tried to add android platform in my project, but when i add android platform it’s return error

Running command: /Library/WebServer/Documents/xxxxx/platforms/android/cordova/build 
[Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.]
Error: /Library/WebServer/Documents/xxxxx/platforms/android/cordova/build: Command failed with exit code 2
    at ChildProcess.whenDone (/usr/local/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)

Actualy, I’ve already set environment variable in ~/.bash_profile like this

# export ANDROID_HOME="/Users/donny/Documents/android/sdk"
# source ~/.bash_profile

it’s still won’t work, when i ran this command


it’s return blank or empty.

Thank You, Any help will appreciate


try sudo export…

# sudo export ANDROID_HOME="/Users/donny/Documents/android/sdk"

Hi @harshitgoel96, thanks for your response
Yup, it’s has using root access already.

1 Like

and “android” command not in your PATH

you also need to add android to your class path…

android-sdk\build-tools should be set in ur path


Yep, I had already

nano ~/.bash_profile

export PATH=${PATH}:/Users/donny/Documents/android/sdk/platform-tools:/Users/donny/Documents/android/sdk/tools
export ANDROID_HOME=/Users/donny/Documents/android/sdk

it’s work when i type this command

source ~/.bash_profile

then i check my $ANDROID_HOME

$ /Users/donny/Documents/android/sdk

but when i close my terminal and open up again, it return error again T_T
i check $ANDROID_HOME again


by the way, before i upgrade my os x to yosemite everything alright.
any help ?


well this seems to be a problem of the fact that the variable is set only for that particular terminal session, and not for the entire system… i am not an expert with OS X… so u need to figure out how to set the variable for entire system and not for a particular terminal session

You are right @harshitgoel96 :wink:
I just thinking there are any peoples who solving this issue hehehe
and they would like to help me
But thanks @harshitgoel96
By the way, in brew had similar problem OOT 3:

I have this in my path for android sdk.

  export PATH=${PATH}:/Applications/Android\\
  export JAVA_HOME=$(/usr/libexec/java_home)
  export PATH=${JAVA_HOME}/bin:$PATH
  export PATH=/usr/local/bin:$PATH
1 Like

hi @mhartington hanks for your response
Yep, I’ve follow your instruction and execute my bash_profile

# source ~/.bash_profile

it’s works nicely in current terminal when i type android, but when i open up another terminal then type android it’s return

zsh: command not found: android


1 Like

Hmm, so why would you put that in your bash_profile if your terminal uses zsh? If you’re using zsh, you should put this in your zshrc

Also in my case, I installed Android studio to get the sdk so that could be why android isn’t found.

1 Like

by the way, where i have to register ANDROID_HOME in zsh ? i don’t know exactly …
I’m using eclipse, is it different or there is have plus options ?


Hi all,

Helpful hint for linux users who find themselves here. Make sure your editing the right .bash_profile, I kept getting the above error response until I realized I was editing the “/home/user/.bash_profile” instead of the “/root/.bash_profile”

OPEN terminal as root

nano ~/.bash_profile

export ANDROID_HOME=/root/Android/Sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools


source ~/.bash_profile

Hi @Isiaha
Thanks for your response
I’ve already edit .bash_profile inside root directory. check this out

and for this

# source ~/.bash_profile

it success, but when i open another tab/terminal or after restarting the computer, it’s return error/blank again ~_~


I get the same error on ubuntu despite having ANDROID_HOME on my path. I have no idea what the problem is. The path is set in my .profile file.

Upgrade warning - for the CLI to run correctly,
it is highly suggested to upgrade the following:

Please update your Node runtime to version >=0.12.x

Running command: /home/johnboy14/ionic/myApp/hooks/after_prepare/010_add_platform_class.js /home/johnboy14/ionic/myApp
add to body class: platform-android
Running command: /home/johnboy14/ionic/myApp/platforms/android/cordova/build
[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.]
ERROR building one of the platforms: Error: /home/johnboy14/ionic/myApp/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: /home/johnboy14/ionic/myApp/platforms/android/cordova/build: Command failed with exit code 2
at ChildProcess.whenDone (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:139: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)

make sure you wrote environment variable in the right place

$ cd $HOME
$ nano .bash_profile

do not wrote if u are in root access like this

# cd $HOME
# nano .bash_profile

just make sure after u are in the right place type this

$ pwd

it should print /Users/your_user

if you are in root access it will print /var/root

I hope it help you
Thank you

I’ve set the variable in my .profile, .bashrc and bash_profile files and I still get the same error. It is set as an environment variable.

:~/ionic/myApp$ env

What about your PATH?
Does it work when you run android command ?

yes. Both Android, Cordova and Ionic are on the path.

just make sure u add $PATH at the last of your environment path

for example

$ cd $HOME
$ nano .bash_profile

then it will open the nano editor

# your path
export PATH = "/directory/path:$PATH"

then save that, after that you have to execute this command to make sure your new path is registered

$ source .bash_profile

to test if your new path has registered just type this

$ echo $PATH

i hope it will help you


It is currently on my path.

/ionic$ echo $PATH