Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.
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.
Related videos on Youtube
rrvasanth
Updated on January 23, 2022Comments
-
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)
What do I do to ensure Android is set up correctly for use with Cordova?
-
Saurabh Bhandari about 5 yearsANDROID_HOME is depreciated now use ANDROID_SDK_ROOT. for more info follow this stackoverflow.com/a/55508862/6190043
-
-
natur3 over 9 yearsis 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\android-sdk -- press enter then re-run the cordova platform add android and the package and project will get created.
-
Ran Davidovitz over 9 yearsHow can we update the documentation for Cordova? (instead of jumping between install and stackoverflow)
-
huggie over 9 yearsI got nothing when I typed android. I can't find and sdk directory under
Android Studio.app
. -
huggie over 9 yearsIn my case the Android studio setting (File->Project structure->SDK) points back to ADT bundle (/Applications/adt-bundle-mac-x86_64-20130729/)...
-
jessiPP over 9 yearsthis 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 over 9 yearsFor 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 over 9 yearsfor me: export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/tools/
-
NBoymanns over 9 yearsThanks 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 over 9 yearsInclude the PATH in the .bash_profile file. I added instructions in the previous comment.
-
Abhijeet over 9 yearsJust 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 over 9 yearsDo 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 about 9 yearsThis 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 about 9 yearsTo 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 almost 9 yearsnote that sometimes your $PATH variable get's pretty messy, and cannot be longer than 256 symbols, so u should use helper vars
-
hash almost 9 yearsSorry i didn't understand.how can i use helper vars?
-
Bhupinder almost 9 yearsI 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 about 8 yearsThis post is for windows.
-
Ruwantha almost 8 yearsYou may need to get new CMD after setting the ANT_HOME
-
whyoz almost 8 yearsyou 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 almost 8 yearsNot working for me ?? My SDK location is in E drive.. whether it should be in C drive ??
-
mhcarneiro over 7 yearsPerfect, I needed to restart my computer for it to work, but it did.
-
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 about 5 yearsI just inserted the variables in this file:
sudo nano ~/.bash_profile
-
Dev Yego over 4 years@lgm, was it necessary to include the
ANDROID_TOOLS
andADROID_PLATFORM_TOOLS
? -
Dev Yego over 4 yearsWouldn't these settings be lost when you reboot? I mean just exporting them this way without actually touching the .bashrc file.
-
Quique over 4 yearsAs it says above: add this to the end of your .bashrc, .profile or appropriate file
-
TipVisor about 4 yearsHow to check if the ANDROID_HOME path is correct by a command prompt?
-
roshnet almost 4 yearsFor those who are gonna copy this,
platforms-tools
should beplatform-tools
. -
Madhu Velpuri about 3 yearsi 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 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).