Finding Android SDK on Mac and adding to PATH
Asked Answered
R

10

315

I have installed Android Studio on my MacBook Air (OS Version 10.11 El Capitan) and have successfully written a small "hello, world" app and installed on device (Nexus 7) and ran on AVD. All I want to do now is be able to build the app and install it on device from the command line as opposed to Android Studio. I'm following the directions here:

http://developer.android.com/training/basics/firstapp/running-app.html

and the relevant line is:

Make sure the Android SDK platform-tools/ directory is included in your PATH environment variable, then execute:

The problem is I can't find the Android SDK on my machine! I assume it's there because otherwise the program wouldn't compile and run through Android Studio? Perhaps that's a bad assumption? I'm new to Macs (I'm used to Windows) so I don't know the best way to search for the Android SDK. So my questions:

  1. How do I find Android SDK on my machine? Or prove to myself it's not there?
  2. If it's not there how do I install it?
  3. How do I change PATH to include Android SDK?
Rondi answered 30/12, 2015 at 15:10 Comment(4)
try searching here /Library/Android/sdk/Standford
you need to export 2 paths -- #18143683Awhile
you can find the path in your sdk manager: Android Studio->Preferences->Appeareance & Behavior->System Settings->Android SDK-> here Android SDK LocationGarnish
Try /Users/<your_user>/Library/Android/sdkSlay
C
540

1. How to find it

  • Open Android studio, go to Android Studio > Preferences
  • Search for sdk
  • Something similar to this (this is a Windows box as you can see) will show

You can see the location there – most of the time it is:

/Users/<name>/Library/Android/sdk

2. How to install it, if not there

Standalone SDK download page

3. How to add it to the path

Open your Terminal edit your ~/.bash_profile file in nano by typing:

nano ~/.bash_profile

If you use Zsh, edit ~/.zshrc instead.

Go to the end of the file and add the directory path to your $PATH:

export PATH="${HOME}/Library/Android/sdk/tools:${HOME}/Library/Android/sdk/platform-tools:${PATH}"
  • Save it by pressing Ctrl+X
  • Restart the Terminal
  • To see if it is working or not, type in the name of any file or binary which are inside the directories that you've added (e.g. adb) and verify it is opened/executed
Carlycarlye answered 30/12, 2015 at 15:22 Comment(7)
Thanks. I followed step 1 and saw the path was: /Users/user/Library/Android/sdk Curiously, using "Finder" and Go->Go To Folder, I couldn't get to it by drilling down from /Users/user/Library etc. The user directory did not show Library! Must be some strange Mac thing. I had to put the full path in Finder.Rondi
For posterity, this link might be useful for adding to PATH: osxdaily.com/2014/08/14/add-new-path-to-path-command-line I had to manually type the path in for the export. Nowhere in "Finder" did I see a copy directory name like in Windows. Sigh...Rondi
Restart the Terminal after you safed the /etc/paths fileCircumambulate
Recommend not edit /etc/path directly. use "export" in ~/.bash_profile instead. Ex. export PATH="/Users/<user_name>/Library/Android/sdk/platform-tools/":$PATH after add above to ~/.bash_profile just use source ~/.bash_profile if there is no error you can freely to use adb commandHarris
Thanks this worked perfectly for me. I had tried to export in ~/.back_profile but that did not work at all.Ecospecies
Nice post! To me, these are all things that could happen automatically when installing the sdk though... 🤔Demonolatry
Thanks, only difference I had is, I had to use open .zprofile, and update the exports there since it is M1 chip (zsh)Senary
S
58

If you don't want to open Android Studio just to modify your path...

They live here with a default installation:

${HOME}/Library/Android/sdk/tools
${HOME}/Library/Android/sdk/platform-tools

Here's what you want to add to your .bashwhatever

export PATH="${HOME}/Library/Android/sdk/tools:${HOME}/Library/Android/sdk/platform-tools:${PATH}"
Stat answered 29/3, 2017 at 18:56 Comment(1)
it works for mac user, must try, thank you :)Cresting
M
21

Find the Android SDK location

Android Studio 
  > Preferences
  > Appearance & Behaviour
  > System Settings 
  > Android SDK
  > Android SDK Location

Create a .bash_profile file for your environment variables

  • Open the Terminal app
  • Go to your home directory via cd ~
  • Create the file with touch .bash_profile

Add the PATH variable to your .bash_profile

  • Open the file via open .bash_profile
  • Add export PATH=$PATH: [your SDK location] /platform-tools to the file and hit ⌘s to save it. By default it's:

    export PATH=$PATH:/Users/yourUserName/Library/Android/sdk/platform-tools

  • Go back to your Terminal App and load the variable with source ~/.bash_profile

Monomania answered 6/6, 2017 at 6:39 Comment(0)
M
13
  1. How do I find Android SDK on my machine? Or prove to myself it's not there?

When you install Android studio, it allows you to choose if you want to download SDK or not

  1. If it's not there how do I install it?

you can get SDK from here http://developer.android.com/sdk/index.html

  1. How do I change PATH to include Android SDK?

in Android Studio click in File >> Settings enter image description here

Misdeem answered 30/12, 2015 at 15:30 Comment(0)
I
9

If Android Studio shows you the path /Users/<name>/Library/Android/sdk but you can not find it in your folder, just right-click and select "Show View Option". There you will be able to select "Show Library Folder"; select it and you can access the SDK.

Intoxicated answered 28/6, 2017 at 13:0 Comment(0)
M
7

I found it here: /Users//Library/Android/sdk

and Platform-tools is available as well

enter image description here

Misunderstood answered 12/2, 2023 at 11:6 Comment(1)
/Users/L... and not /Users//. ?Acetal
N
6

The default path of Android SDK is /Users/<username>/Library/Android/sdk, you can refer to this post.

add this to your .bash_profile to add the environment variable

export PATH="/Users/<username>/Library/Android/sdk/tools:/Users/<username>/Library/Android/sdk/build-tools:${PATH}"

Then save the file.

load it

source ./.bash_profile 
Nickels answered 6/6, 2017 at 6:6 Comment(0)
M
0

AndroidStudioFrontScreenI simply double clicked the Android dmg install file that I saved on the hard drive and when the initial screen came up I dragged the icon for Android Studio into the Applications folder, now I know where it is!!! Also when you run it, be sure to right click the Android Studio while on the Dock and select "Options" -> "Keep on Dock". Everything else works. Dr. Roger Webster

Moniquemonism answered 16/1, 2019 at 11:21 Comment(0)
S
0

For Visual Studio for Mac users (e.g. who installed Android SDK together with VS):

  • open Visual Studio for Mac
  • select from menu: Tools -> SDK Manager -> Select 3rd tab: 'Localizations' in dialog

You can find JDK, Android NDK and Android SDK localizations there (if installed and selected). If no Android SDK path found, you may try to find it using Android Studio (if it is installed)

Schoolboy answered 12/1, 2021 at 22:39 Comment(0)
A
0

In my case, I had to create local.properties file with sdk.dir=PATH_TO_ANDROID_SDK in my machine. It seems that, it's regarding the android sdk path setup. Hence, it could also be set in ANDROID_HOME env. variable too.

Aetolia answered 14/1, 2021 at 12:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.