-bash: android: command not found on Mac OSX
Solution 1
The android
tool is located in the tools
directory in your SDK. You need to add this to your PATH
environment variable so that bash can recognize it.
You can do this by adding it to your PATH
in your .bash_profile
file. This file should be located in your home directory. Create if it doesn't exist using vi .bash_profile
and add the following line to it:
export PATH=<path_to_android_sdk>/platform-tools:<path_to_android_sdk>/tools:$PATH
where <path_to_android_sdk>
is to be replaced with the path to your SDK. For example: "/Users/me/android-sdk-mac_86/platform-tools"
Solution 2
Step 0
The first step is install Android SDK: https://developer.android.com/studio
I don't like the default configurations. I installed SDK in this folder:
/Users/<Username>/Android\ SDK
ℹ️ The default path is
$HOME/Library/Android/sdk
Step 1
The next command open your bash or zshrc configuration file:
Bash profile:
vim ~/.bash_profile
If you use zsh:
vim ~/.zshrc
Step 2
You're ready to update your configurations:
# File: .bash_profile | .zshrc
# Custom path to Android SDK folder.
# If you use the default configuration please change ANDROID_HOME to $HOME/Library/Android/sdk
export ANDROID_HOME=/Users/<Username>/Android\ SDK
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
Step 3
Option 1:
Restart your terminal and you should be able to use android
command
Option 2: source your bash
or zsh
profile.
Example: source ~/.bash_profile
/ source ~/.zshrc
Solution 3
I spent so much time trying to figure out, this steps helped me ( from http://docs.phonegap.com/en/2.2.0/guide_getting-started_android_index.md.html )
You need to execute your .bash_profile
to update your PATH
.
Set up your PATH environment variable on Mac OS
Open the Terminal program (this is in your Applications/Utilites folder by default). Run the following command
touch ~/.bash_profile; open ~/.bash_profile
This will open the file in the your default text editor. You need to add the path to your Android SDK platform-tools and tools directory. In my example I will use "/Development/android-sdk-macosx" as the directory the SDK is installed in. Add the following line:
export PATH=${PATH}:/Development/android-sdk-macosx/platform-tools:/Development/android-sdk-macosx/tools
Save the file and quit the text editor. Execute your .bash_profile
to update your PATH:
source ~/.bash_profile
Now every time you open the Terminal program you PATH
will included the Android SDK.
Solution 4
Problem Solved For Android Studio Users:
I am using Mac OS X Elcapitan version 10.11.X.
Under my home directory I found .bash_profile.save file. I opened that file using sublime (you can use any other editor). Then I added this line
export PATH=${PATH}:/Users/UserName/Library/Android/sdk/platform-tools:/Users/UserName/Library/Android/sdk/tools
Replace "UserName" with your UserName.
open terminal then run
source ~/.bash_profile
here you go.
Solution 5
First add these lines to your ~/.bashrc file:
export ANDROID_HOME=${HOME}/Library/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
then:
source ~/.bashrc
kramer65
Updated on August 11, 2021Comments
-
kramer65 over 2 years
I've been diving into Android development for a while, and now I want to use some project (helpshift) in my app. On the website they have some example apps in which the readme says: Run the following inside the /HelpshiftDemo folder.
android update project -t android-17 -p .
So I do this, but unfortunately this gives me an error saying
-bash: android: command not found
. I understand this, because "android" as such doesn't refer to anything on my laptop (Mac OSX). So I thought it is maybe referring to the adb. So I tried replacingandroid
for the direct path to my adb:/Users/kramer65/dev/adt-bundle-mac-x86_64-20130917/sdk/platform-tools/adb update project -t android-17 -p .
This gives me a humongous output with more information on adb, which is I guess not the expected result.
So my questions; what does
android
refer to, and how can I fix this on Mac OSX? -
Jono almost 10 yearsWorked perfectly for me! Of course you have to make sure that you remove the '<' and '>' as well as the text. My path was /Users/my_user_name/android-sdks so my total added to my .bash_profile was literally: export PATH=/my_user_name/android-sdks/platform-tools:/my_user_name/android-sdks/tools:$PATH
-
Splaktar over 9 yearsThis worked for me previous, but with the last update to OS X Mavericks it stopped. I still see the entries in the PATH, but adb cannot be resolved. It works if I run it locally via ./adb but not with just 'adb'.
-
brentonstrine over 9 yearsThank you! This actually helped me get it working. The other answers were probably correct but this helped me identify what I was doing wrong and was also much simpler to set up!
-
Bruno Bronosky about 9 yearsI installed Android Studio from developer.android.com/sdk/index.html with the default options and the value for ANDROID_HOME needed to be
export ANDROID_HOME=$HOME/Library/Android/sdk
-
d.danailov about 9 yearsDo you see my comment? "# !!! Change this configuration path. I install Android SDK in my local Mac directory."
-
Bruno Bronosky about 9 yearsI see your comment and raise you the information needed for a default Android Studio install. Telling people they need to change it doesn't tell them what to change it to or how to find the answer. I'm just trying to help people out. It's not an indictment. It would be useful to tell people they can find the (uniquely and consistently named) platform-tools folder via
find / -name platform-tools 2>/dev/null
and the parent folder will be the sdk/ANDROID_HOME path. -
nerdess almost 9 yearsthix this worked perfectly for me! just for reference, this is what i added to my .bash_profile and then restarted the terminal: export ANDROID_HOME=$HOME/Library/Android/sdk export PATH=$HOME/Library/Android/sdk/tools:$PATH export PATH=$HOME/Library/Android/sdk/platform-tools:$PATH
-
Laser Hawk almost 9 yearsAwesome this is the best way to correct the problem and the simplest. This also highlighted a new issue. I installed Android Studio and updated through the SDK manger within the IDE. After following your instructions and getting the 'android' command to work it brought up another SDK manger view that showed the API's i previously updated in Android Studio were not actually updated. Not sure how I have two SDK instances or where that disconnect is.
-
Phil Hudson over 8 yearsGreat but restarting terminal wasn't enough for me, I needed to run
source ~/.bash_profile
-
d.danailov over 8 yearsAdd information for bash and zsh. @PhilHudson thank you very much.
-
Nininea about 8 yearsI have to added following Line : export PATH=/User/username/Library/Android/sdk/platform-tools:/User/username/Library/Android/sdk/tools:$PATH restard my terminal, but still not working :( help
-
Nininea about 8 yearsoops , my fault - I had to write Users instead of User in the path ^_^ it works perferct
-
pmont about 6 yearsIn 2018, the Android SDK install path on OSX is /Users/<USERNAME>/Library/Android/sdk
-
Berry Blue over 4 yearsDoes this still work in Catalina? I can't get this to work.
-
slothstronaut over 4 yearsThis should no longer be a top answer, this path is out of date and not correct.
-
d.danailov over 4 years@Eduardo thank you very much for the commend and for the feedback. I've updated my answer. Do you think the current version is helpful ?
-
omkar about 4 yearsadb command is working but android 'command not found' occurs