30

Where does homebrew install the android-sdk when you run the command:

brew cask install android-sdk

I want to be able to add it to the PATH.

Endareth
  • 492
  • 3
  • 15
hopper
  • 4,230
  • 8
  • 36
  • 49

7 Answers7

44

use brew info --cask android-sdk

after installing, you can get some basic information about what needs to be set and where:

› brew cask info android-sdk
...etc
/usr/local/Caskroom/android-sdk/3859397,26.0.1/build-tools/26.0.1/aapt (binary)
/usr/local/Caskroom/android-sdk/3859397,26.0.1/tools/bin/avdmanager
...etc

==> Caveats
We will install android-sdk-tools, platform-tools, and build-tools for 
you. You can control android sdk packages via the sdkmanager command.
You may want to add to your profile:

  'export ANDROID_SDK_ROOT=/usr/local/share/android-sdk'

notes

Prior to March 2017 you could run brew info android-sdk

Stanislav Mayorov
  • 4,298
  • 5
  • 21
  • 44
random-forest-cat
  • 33,652
  • 11
  • 120
  • 99
18

The installation folder of android-sdk is:

/usr/local/Cellar/android-sdk/<VERSION>

Therefore, if you want to add it to PATH, you need to add the following line to ~/.bashrc

export PATH=$PATH:/usr/local/Cellar/android-sdk/<VERSION>/tools:/usr/local/Cellar/android-sdk/<VERSION>/platform-tools

Don't forget to replace <VERSION> with an installed version, just take a look inside of android-sdk folder to see what version you have installed.

Rodrigo Ayala
  • 500
  • 5
  • 7
  • 9
    The install is symlinked via the usual `/usr/local/` paths setup in the `$PATH` when initially setting up Homebrew--**so no special configuration is needed**. ``export PATH=/usr/local/bin:/usr/local/sbin:/usr/local/opt:/usr/bin:/usr/sbin:$PATH``. @kornfridge note below ``brew info`` answer points out ``export ANDROID_HOME=/usr/local/opt/android-sdk``. **Using this approach instead of the one above allows update+upgrade without constantly editing the path/env.** Note too the path search order affects command use, so I have ``$PATH`` appended, not prepended. – jimmont May 31 '15 at 22:59
  • 1
    As others have stated, `export ANDROID_HOME=/usr/local/opt/android-sdk` is the best option. – Franco Dec 24 '16 at 16:39
  • 4
    This is no longer true, since `android-sdk` was moved from `homebrew/core` to `caskroom/cask`. See my answer for more details of the changes. – Endareth Sep 14 '17 at 03:57
  • this is all wrong, misleading, time-wasting babble and should be removed. it's in none of these places. – johnrubythecat Aug 29 '18 at 01:45
16

Unfortunately, brew has now changed where android-sdk is installed, so all of these older questions are no longer correct.

When installing via brew cask install android-sdk, you'll now be informed that you should add export ANDROID_SDK_ROOT=/usr/local/share/android-sdk to your profile, and, indeed, that directory is now a symlink to the version android-sdk directory (currently /usr/local/Caskroom/android-sdk/25.2.3).

To summarise, add the following to your .profile/.bashrc/.whatever:

export ANDROID_SDK_ROOT=/usr/local/share/android-sdk

export PATH=$PATH:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools

Endareth
  • 492
  • 3
  • 15
  • Thanks @Endareth, but I have 1 issue - my ANDROID_SDK_ROOT and ANDROID_HOME and ANDROID_SDK_HOME all point to the same location as mentioned above and when I create emulator it gets created inside /usr/local/share/android-sdk/.android/avd even after I explicitly provide different path (Users/me/.android/sdk) to avdmanager create command. Any idea what could be the reason behind it? – Awadhoot Jan 17 '19 at 13:21
11

You would be better off using the symlink that Homebrew creates to ANDROID_HOME, as it will always be the newest version:

/usr/local/opt/android-sdk/

So your PATH would be:

export PATH=$PATH:/usr/local/opt/android-sdk/tools:/usr/local/opt/android-sdk/platform-tools

olimortimer
  • 1,373
  • 10
  • 23
1

in my machine, at /usr/local/share/android-sdk

Kai
  • 679
  • 9
  • 11
1

My Homebrew installation (brew install --cask android-platform-tools) use this Path:

/usr/local/Caskroom/android-platform-tools/30.0.0/platform-tools

0

Homebrew installs things in the Cellar:

/usr/local/Cellar

Travis
  • 2,579
  • 18
  • 19