17

I have just installed Android Studio 0.2.2. I want to add the SDK tools to the $PATH, which are in this folder:

/Applications/Android\ Studio.app/sdk/tools

so that I can use them with e.g. Phonegap.

But after I add this folder to the $PATH, it still keeps saying:

android: command not found

Oddly, I can't run any of the executables in that folder even when I cd to that folder and type their names.

What am I doing wrong?

nbro
  • 15,395
  • 32
  • 113
  • 196
keune
  • 5,779
  • 4
  • 34
  • 50

5 Answers5

62

It seems that newer versions of Android Studio don't come bundled with the SDK. So, /Applications/Android\ Studio.app/sdk/tools will no longer work.

After launching the SDK Manager from Android Studio, I realized the new path is /Users/$USER/Library/Android/sdk/tools.

Steps

  1. Open your ~/.bash_profile file by issuing the command open ~/.bash_profile on the terminal

  2. Add the following lines to the end of that file

    1. export PATH=/Users/$USER/Library/Android/sdk/tools:$PATH
    2. export PATH=/Users/$USER/Library/Android/sdk/tools/bin:$PATH
    3. export PATH=/Users/$USER/Library/Android/sdk/platform-tools:$PATH
  3. Save and close the ~/.bash_profile file

  4. If you want the changes to take action on the current terminal, then source ~/.bash_profile; otherwise, close and re-open the terminal, and the changes will take place automatically

nbro
  • 15,395
  • 32
  • 113
  • 196
Nestor Turizo
  • 760
  • 7
  • 10
10

You can add this folder to you PATH in .bash_profile (a hidden file in the home folder of the user):

export PATH=/Applications/Android\ Studio.app/sdk/tools:$PATH

and then reopen the terminal application.

If you need an environment for all your UI apps, you can use the .launchd.conf (or /etc/launchd.conf for all the users).

tiziano
  • 314
  • 1
  • 10
  • i have already added it to path, my problem is that it still says command not found. – keune Aug 09 '13 at 10:34
  • /Users/keune/.rvm/gems/ruby-1.9.2-p320/bin:/Users/keune/.rvm/gems/ruby-1.9.2-p320@global/bin:/Users/keune/.rvm/rubies/ruby-1.9.2-p320/bin:/Users/keune/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Applications/Android\ Studio.app/sdk/tools/:/usr/local/git/bin:/usr/local/mysql/bin – keune Aug 09 '13 at 13:21
  • Very strange. It works form me. You are trying to execute "android" command from bash, right? – tiziano Aug 09 '13 at 14:29
  • Exporting the path in .bash_profile affect only the bash terminal for the user. If you want to set an environment for all the UI apps, you may to edit .launchd.conf. – tiziano Aug 09 '13 at 14:45
  • +1 for telling the .launchd.conf thing. Never knew how to add paths to non-terminal stuff in OS X (never ever needed it, either!) – akauppi Feb 20 '14 at 17:36
  • anyone who can't get it to work yet then try writing ./adb instead of adb . It works. Like in this case it didn't work for me and then i added ./ infront and it works. voila – VarunJoshi129 Apr 20 '16 at 14:55
7

Put this in your ~/.profile:

# Add the Android SDK tools to $PATH and set $ANDROID_HOME (standard)
ANDROID_HOME="${HOME}/Library/Android/sdk"
if [ -d "${ANDROID_HOME}" ]; then
  PATH="${PATH}:${ANDROID_HOME}/tools"
  PATH="${PATH}:${ANDROID_HOME}/platform-tools"
  ANDROID_BUILD_TOOLS_DIR="${ANDROID_HOME}/build-tools"
  PATH="${PATH}:${ANDROID_BUILD_TOOLS_DIR}/$(ls -1 ${ANDROID_BUILD_TOOLS_DIR} | sort -rn | head -1)"
fi

The build tools are unlike the others in that they're in subfolders. Eg there's build-tools/23.0.3, build-tools/25.0.1, build-tools/25.0.2... so this chooses the most recent one.

David Lord
  • 628
  • 10
  • 29
2

You are getting bit by the escape character.

The reason tiziano's answer works for him is because the export command needs that backslash after "Android"

however, you are probably editing /etc/paths. When you put the path in there, you don't need the backslash, just put the lines:

/Applications/Android Studio.app/sdk/tools /Applications/Android Studio.app/sdk/platform-tools

in /etc/paths, and you are good to go.

user272847
  • 21
  • 1
0

For me it was

~/Development/adt-bundle-mac-x86_64-20130729/sdk
ergunkocak
  • 3,334
  • 1
  • 32
  • 31