Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.

574,336

Solution 1

For Windows:

    set ANDROID_HOME=C:\ *installation location* \android-sdk
    
    set PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools

Taken from this installation guide.

Solution 2

For Mac OS X:

export ANDROID_HOME=/<installation location>/android-sdk-macosx
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

Solution 3

I have MAC OS X Yosemite, Android Studio 1.0.1, JDK 1.8, and Cordova 4.1.2

When I tried to add the android project:

cordova platforms add android

I received the message: ANDROID_HOME is not set and "android" command not in your PATH

Based in cforcloud's answer... 'Error: the command "android" failed' using cordova and http://developer.android.com/sdk/installing/index.html?pkg=studio I used the following:

export ANDROID_HOME="/Users/<user_name>/Library/Android/sdk"
export ANDROID_TOOLS="/Users/<user_name>/Library/Android/sdk/tools/"
export ANDROID_PLATFORM_TOOLS="/Users/<user_name>/Library/Android/sdk/platform-tools/"
PATH=$PATH:$ANDROID_HOME:$ANDROID_TOOLS:$ANDROID_PLATFORM_TOOLS
echo $PATH

When I tried to create the android project, I received this message:

Creating android project...
/Users/lg/.cordova/lib/npm_cache/cordova-android/3.6.4/package/bin/node_modules/q/q.js:126
                    throw e;
                          ^
Error: Please install Android target "android-19".

I ran Android SDK Manager, and installed Android 4.4.2 (API 19) (everything but Glass Development Kit Preview). It worked for me.

===

This is the content of my .bash_profile file.

export PATH=$PATH:/usr/local/bin
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
launchctl setenv STUDIO_JDK /library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk
export ANDROID_HOME="/Users/<UserName>/Library/Android/sdk"
export ANDROID_TOOLS="/Users/<UserName>/Library/Android/sdk/tools"
export ANDROID_PLATFORM_TOOLS="/Users/<UserName>/Library/Android/sdk/platform-tools"
PATH=$PATH:$ANDROID_HOME:$ANDROID_TOOLS:$ANDROID_PLATFORM_TOOLS

To edit .bash_profile using Terminal, I use nano. It is easy to understand.

cd
nano .bash_profile

I hope it helps.

Solution 4

for windows:

Right click on My computer -> properties -> Advanced system setting -> Environment Variables Edit Path on system variables to ;\yourSdkHome\tools;\yourSdkHome\platform-tools.

Then Close your cmd prompt and reopen.

Solution 5

On Linux, add this to the end of your .bashrc, .profile or appropriate file for your shell:

export ANDROID_HOME=/home/youruser/whatever/adt-bundle-linux-x86_64-20140702/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platforms-tools

Please notice that these environment variables will be available for newly created shells, not the already open.

Share:
574,336

Related videos on Youtube

rrvasanth
Author by

rrvasanth

Updated on January 23, 2022

Comments

  • rrvasanth
    rrvasanth over 2 years

    I'm trying to install PhoneGap and I'm getting the following error:

    Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.

    Error (screenshot)

    enter image description here

    What do I do to ensure Android is set up correctly for use with Cordova?

  • natur3
    natur3 over 9 years
    is correct. But just in case it wasnt 100% clear to people like myself, in the cmd window from your c:windows\system32\projectname> directory type the set command above for android_home. Side note when I was working with Android Studio my SDKs by default were installed to the following location: C:\Users\<username>\AppData\Local\Android\android-sdk In short in your cordova directory above type the set ANDROID_HOME=C:\Users\<username>\AppData\Local\Android\andro‌​id-sdk -- press enter then re-run the cordova platform add android and the package and project will get created.
  • Ran Davidovitz
    Ran Davidovitz over 9 years
    How can we update the documentation for Cordova? (instead of jumping between install and stackoverflow)
  • huggie
    huggie over 9 years
    I got nothing when I typed android. I can't find and sdk directory under Android Studio.app.
  • huggie
    huggie over 9 years
    In my case the Android studio setting (File->Project structure->SDK) points back to ADT bundle (/Applications/adt-bundle-mac-x86_64-20130729/)...
  • jessiPP
    jessiPP over 9 years
    this worked for me. Your statement "Please notice that these environment variables will be available for newly created shells, not the already open." is what helped me to realize i have to redo this.
  • Svavar
    Svavar over 9 years
    For me my <installation location> was ~/adt-bundle-mac-x86_64/sdk so the first command was export ANDROID_HOME=~/adt-bundle-mac-x86_64/sdk.
  • AGDM
    AGDM over 9 years
    for me: export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/tools/
  • NBoymanns
    NBoymanns over 9 years
    Thanks this also worked for me! But every time I open a new terminal I must set the PATH, is there a way to do set the PATH permanent?
  • lgm
    lgm over 9 years
    Include the PATH in the .bash_profile file. I added instructions in the previous comment.
  • Abhijeet
    Abhijeet over 9 years
    Just setting the ANDROID_HOME does it for me, additionally had to make sure that I had Android 19.0 installed as I tried to add platform to Android project.
  • rekordboy
    rekordboy over 9 years
    Do you need the braces around the 'PATH' as shown above? I'm having a hello of a time getting my hybrid environment set up. But I am new to mac? I had no issues in windows :| but I still love my new mac!
  • WillJones
    WillJones about 9 years
    This was very clear and worked for me, much better than all the other answers! I didn't know where I would find the SDK on my system.
  • Dibish
    Dibish about 9 years
    To set ANDROID_HOME permanently Right click on My Computer>Properties>Advanced System Settings>Environment variables > 1. Add system variable name = "ANDROID_HOME" value = "E:\Users\user\AppData\Local\Android\sdk" (Enter your android sdk path here) 2. Above system varialbe you can see your PATH, Edit PATH "%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools" save
  • Medet Tleukabiluly
    Medet Tleukabiluly almost 9 years
    note that sometimes your $PATH variable get's pretty messy, and cannot be longer than 256 symbols, so u should use helper vars
  • hash
    hash almost 9 years
    Sorry i didn't understand.how can i use helper vars?
  • Bhupinder
    Bhupinder almost 9 years
    I was facing same issue. Problem in my case was I was not running above commands as root user. I executed as root and everything worked fine.
  • Josh McKearin
    Josh McKearin about 8 years
    This post is for windows.
  • Ruwantha
    Ruwantha almost 8 years
    You may need to get new CMD after setting the ANT_HOME
  • whyoz
    whyoz almost 8 years
    you may need to close and reopen AS a few times for this to take affect...for some reason it started working after changing the variables a few times and restarting AS, then back to this solution and it should work..don't give up on this, even for Android Studio v2
  • Kartiikeya
    Kartiikeya almost 8 years
    Not working for me ?? My SDK location is in E drive.. whether it should be in C drive ??
  • mhcarneiro
    mhcarneiro over 7 years
    Perfect, I needed to restart my computer for it to work, but it did.
  • peteb
    peteb over 7 years
    @Dibish this worked for me. If adding from the GUI, make sure to add the Environment Variables to the System Variables and not the User Variables.
  • Caio Kawasaki
    Caio Kawasaki about 5 years
    I just inserted the variables in this file: sudo nano ~/.bash_profile
  • Dev Yego
    Dev Yego over 4 years
    @lgm, was it necessary to include the ANDROID_TOOLS and ADROID_PLATFORM_TOOLS?
  • Dev Yego
    Dev Yego over 4 years
    Wouldn't these settings be lost when you reboot? I mean just exporting them this way without actually touching the .bashrc file.
  • Quique
    Quique over 4 years
    As it says above: add this to the end of your .bashrc, .profile or appropriate file
  • TipVisor
    TipVisor about 4 years
    How to check if the ANDROID_HOME path is correct by a command prompt?
  • roshnet
    roshnet almost 4 years
    For those who are gonna copy this, platforms-tools should be platform-tools.
  • Madhu Velpuri
    Madhu Velpuri about 3 years
    i did it in Big Sur and using zshenv. but when i close terminals and restart the machine, unable to find saved paths. PATH or ANDROID_HOME or JAVA_HOME
  • Fil
    Fil over 2 years
    @TipVisor: with the command "set". If you have grep for windows your command can be "set | grep -i android_home" to see only one line (is set) or nothing (not set).