882

I spent quite sometime figuring how to set up adb on Mac, so I figure writing how to set it up might be useful to some people. adb is the command line tool to install and run android apps on your phone/emulator

2

33 Answers 33

1874

Note: this was originally written on Installing ADB on macOS but that question was closed as a duplicate of this one.

Note for zsh users: replace all references to ~/.bash_profile with ~/.zshrc.

Option 1 - Using Homebrew

This is the easiest way and will provide automatic updates.

  1. Install homebrew

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
    
  2. Install adb

    brew install android-platform-tools
    

    or try a cask install depending on your settings:

    brew install --cask android-platform-tools
    
  3. Start using adb

    adb devices
    

Option 2 - Manually (just the platform tools)

This is the easiest way to get a manual installation of ADB and Fastboot.

  1. Delete your old installation (optional)

    rm -rf ~/.android-sdk-macosx/
    
  2. Navigate to https://developer.android.com/studio/releases/platform-tools.html and click on the SDK Platform-Tools for Mac link.

  3. Go to your Downloads folder

    cd ~/Downloads/
    
  4. Unzip the tools you downloaded

    unzip platform-tools-latest*.zip 
    
  5. Move them somewhere you won't accidentally delete them

    mkdir ~/.android-sdk-macosx
    mv platform-tools/ ~/.android-sdk-macosx/platform-tools
    
  6. Add platform-tools to your path

    echo 'export PATH=$PATH:~/.android-sdk-macosx/platform-tools/' >> ~/.bash_profile
    
  7. Refresh your bash profile (or restart your terminal app)

    source ~/.bash_profile
    
  8. Start using adb

    adb devices
    

Option 3 - If you already have Android Studio installed

  1. Add platform-tools to your path

    echo 'export ANDROID_HOME=/Users/$USER/Library/Android/sdk' >> ~/.bash_profile
    echo 'export PATH="$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools"' >> ~/.bash_profile
    
  2. Refresh your bash profile (or restart your terminal app)

    source ~/.bash_profile
    
  3. Start using adb

    adb devices
    

Option 4 - MacPorts

  1. Install the Android SDK:

    sudo port install android
    
  2. Run the SDK manager:

    sh /opt/local/share/java/android-sdk-macosx/tools/android
    
  3. Uncheck everything but Android SDK Platform-tools (optional)

  4. Install the packages, accepting licenses. Close the SDK Manager.

  5. Add platform-tools to your path; in MacPorts, they're in /opt/local/share/java/android-sdk-macosx/platform-tools. E.g., for bash:

    echo 'export PATH="$PATH:/opt/local/share/java/android-sdk-macosx/platform-tools"' >> ~/.bash_profile
    
  6. Refresh your bash profile (or restart your terminal/shell):

    source ~/.bash_profile

  7. Start using adb:

    adb devices

Option 5 - Manually (with SDK Manager)

  1. Delete your old installation (optional)

    rm -rf ~/.android-sdk-macosx/
    
  2. Download the Mac SDK Tools from the Android developer site under "Get just the command line tools". Make sure you save them to your Downloads folder.

  3. Go to your Downloads folder

    cd ~/Downloads/
    
  4. Unzip the tools you downloaded

    unzip tools_r*-macosx.zip 
    
  5. Move them somewhere you won't accidentally delete them

    mkdir ~/.android-sdk-macosx
    mv tools/ ~/.android-sdk-macosx/tools
    
  6. Run the SDK Manager

    sh ~/.android-sdk-macosx/tools/android
    
  7. Uncheck everything but Android SDK Platform-tools (optional)

    enter image description here

  8. Click Install Packages, accept licenses, click Install. Close the SDK Manager window.

    enter image description here

  9. Add platform-tools to your path

    echo 'export PATH="$PATH:~/.android-sdk-macosx/platform-tools/"' >> ~/.bash_profile
    
  10. Refresh your bash profile (or restart your terminal app)

    source ~/.bash_profile
    
  11. Start using adb

    adb devices
    
15
  • 3
    this is far more straightforward than chasing down the sdk path which keeps changing.
    – Tyler Zale
    Commented May 11, 2016 at 18:45
  • 1
    Has now moved to cask: brew cask install android-platform-tools
    – hoju
    Commented Apr 7, 2017 at 14:53
  • For create file if not available perform with terminal $Touch .bash_profile For open and edit file $open -e .bash_profile in file type it export JAVA_HOME=$(/usr/libexec/java_home) export ANDROID_HOME=/Users/user_name/Library/Android/sdk export PATH=$ANDROID_HOME/platform-tools:$PATH export PATH=$ANDROID_HOME/tools:$PATH then file>save After restart Terminal app and enjoy. Commented Nov 8, 2017 at 13:16
  • 4
    I already have Android studio so I tried 3. It works after I run source ./bash_profile but only persists as long as the terminal is open.
    – bikram
    Commented Mar 27, 2020 at 16:15
  • 4
    On MacOS Catalina and higher settings should be exported to .zprofile .
    – rule
    Commented Dec 18, 2020 at 10:15
613

echo "export PATH=\$PATH:/Users/${USER}/Library/Android/sdk/platform-tools/" >> ~/.bash_profile && source ~/.bash_profile

If you put the android-sdks folder in other directory, replace the path with the directory android-sdks/platform-tools is in

10
  • 70
    And for those who use zsh instead bash, you'll need to add this to ~/.zshrc Commented Sep 5, 2013 at 1:17
  • 15
    You've also gotta Quit and reopen your Terminal for the changes to take effect
    – amadib
    Commented Feb 8, 2014 at 1:07
  • 38
    As of Android Studio 1.0 Location of platform tools is echo 'export PATH=$PATH:/Users/[yourusername]/Library/Android/sdk/platform-tools' >> ~/.bash_profile Commented Dec 16, 2014 at 6:50
  • 13
    No need to quit and reopen the Terminal, you can just source ~/.bash_profile.
    – Nighto
    Commented Apr 13, 2015 at 1:46
  • 10
    You can use $HOME instead of "/Users/[yourusername]"
    – Jason Cox
    Commented Apr 29, 2016 at 18:17
175

Only for zsh users in Terminal or iterm2 in macOS

type the following two commands to add the android sdk and platform-tools to your zsh in Terminal or iterm2 in macOS

echo 'export ANDROID_HOME=/Users/$USER/Library/Android/sdk' >> ~/.zshrc
echo 'export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools' >> ~/.zshrc

After adding the two command to ~/.zshrc you need to source the zsh.

source ~/.zshrc
8
  • 4
    This is what I was looking for! :) Thanks! Also, don't forget to run source .zshrc or reopen terminal. :D
    – rafaelbpa
    Commented Aug 23, 2019 at 16:51
  • You are welcome. edited the answer and add a source to zsh command. Commented Oct 31, 2019 at 12:11
  • What do i need to put instead of the $PATH and $ANDROID_HOME? Commented Jan 22, 2020 at 14:42
  • 1
    works like a charm on the M1 mac! thank you! I wasn't aware of the zsh and bash thing are now updated. used mac after like 4 years!
    – sud007
    Commented Jul 17, 2021 at 12:06
  • 2
    PS not just iTerm2 it works fine in terminal too. So thanks again!
    – sud007
    Commented Jul 17, 2021 at 18:46
117

This Works Flawless....

In terminal Run both commands next to each other

export ANDROID_HOME=/Users/$USER/Library/Android/sdk

export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
7
  • 2
    I can confirm that this works great as of June 2017 on macOS Sierra. Commented Jun 2, 2017 at 20:31
  • sdk folder has been removed. If those two commands were run, adb devices won't work. Should be the following for latest android studio ` export ANDROID_HOME=/Users/$USER/Library/Android export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools `
    – Liangjun
    Commented Jun 5, 2017 at 2:17
  • Thanks its help me but make sure change after $USER path with your directory of sdk
    – abadooz
    Commented Oct 30, 2018 at 8:22
  • 1
    As of android studio 3.2, the path is defaulted to '$HOME/Library/Android/sdk'
    – tsalaroth
    Commented Nov 3, 2018 at 11:02
  • Thank you. You helped me a lot Commented Nov 9, 2019 at 15:17
73

2022 Solution

If you have Android Studio installed already and Terminal isn't picking up ADB, here's a one-liner that should fix it:

sudo ln -s ~/Library/Android/sdk/platform-tools/adb /usr/local/bin

It creates a symbolic link (essentially a shortcut) for the adb executable. It's added to /usr/local/bin which is one of the default locations where Terminal looks for command line tools.

2
  • Could you explain what happens in this? what is ln and -s? Commented Nov 10, 2022 at 10:20
  • 2
    It creates a symbolic link (essentially a shortcut) for the adb executable. It's added to /usr/local/bin which is one of the default locations where Terminal looks for command line tools.
    – Lorenzo
    Commented Nov 11, 2022 at 5:12
60

NOTE: Path for adb has changed since Android Studio 1.0.xx

For bash shell, use:

echo 'export PATH=$PATH:'$HOME'/Library/Android/sdk/platform-tools' >> ~/.bash_profile

For tcsh shell, use:

echo 'setenv PATH $PATH\:'$HOME'/Library/Android/sdk/platform-tools' >> ~/.tcshrc
4
  • This is indeed where the tools are located in the latest version
    – Yablargo
    Commented Dec 24, 2014 at 13:22
  • 2
    I have 1.0.1 and I don't have anything there :/
    – htafoya
    Commented Jan 13, 2015 at 5:17
  • Command for bash shell and Eclipse is echo 'export PATH=$PATH:/Applications/adt-bundle-mac-x86_64/sdk/platform-tools/' >> ~/.bash_profile Commented Feb 18, 2015 at 0:51
  • 2
    Android Studio 2.0 and that's still the location - ~/Library/Android/sdk/platform-tools
    – galdin
    Commented Apr 18, 2016 at 8:02
48

If you are using zsh shell and after trying all this solutions, you still need to set $PATH and $ANDROID_HOME every time you open new terminal instance, then here is your answer:

step 1: in terminal run nano ~/.zshrc

step 2: paste following command at the end of the file

export ANDROID_HOME=~/Library/Android/sdk
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH

step 3: After copying the lines above, to save hit control + X. and to confirm hit Y. It will ask you if you wish to change the file name but don't change the name so directly hit enter

step 4: Restart your terminal and execute the adb command.

Bingo!

3
  • 1
    You might want to use this to be user name independent: export ANDROID_HOME=~/Library/Android/sdk Commented Dec 15, 2021 at 10:07
  • @MichaelTroger well said, I've updated the answer with your help! thanks Commented Dec 16, 2021 at 19:50
  • To avoid conflicts with vscode use this solution in macos 11 or higher. stackoverflow.com/a/72206562/7621800 Commented Nov 1, 2022 at 10:59
26

Here is a step wise information :

Step-1

Start up Terminal and go to your home folder.

cd ~/

Step-2

Open and edit .bash_profile file

$ open -e .bash_profile

If you don’t have .bash_profile file in your computer path, then create one. Enter below command to create a new file. Once created follow Step-2.

touch .bash_profile

Step-3

Save the below line)

export PATH=${PATH}:/Applications/adt-bundle-mac-x86_64-20140321/sdk/tools
export PATH=${PATH}:/Applications/adt-bundle-mac-x86_64-20140321/sdk/platform-tools

Step-4

Refresh the file using below command

$ source .bash_profile

$ echo $PATH

You should see your android path set in the output now.

0
26

Personally I just source my .bashrc in my .bash_profile:

echo 'source ~/.bashrc' >> ~/.bash_profile

So I put it in my .bashrc. And I'm using Android Studio, so it was a different path.

echo 'PATH=$PATH:$HOME/Library/Android/sdk/platform-tools/' >> ~/.bashrc

You may also want the following:

echo 'ANDROID_HOME=$HOME/Library/Android/sdk' >> ~/.bashrc
20

The simplest way to use adb command on your Mac systems would be to add the path to the platform-tools (where adb lives) into your bash_profile.

Steps to add the adb path: 1. open the bash_profile: This can be done by using the following commands

open ~/.bash_profile

This opens up the bash_profile in an editor.

  1. Locate the platform_tools, usually they are present at the following location: Users/"user_folder"/Library/Android/sdk/platform_tools

  2. Paste the following command in the bash_profile file which opens up:

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

  3. Save the file using the command:

source ~/.bash_profile

  1. Check if the path is saved by typing: echo $PATH : You should be able to find the entire path displayed in the output.

  2. Type adb to see if the configuration worked. If you have any devices connected to the machine or any emulators running on your system they would be displayed when you type adb devices

output for adb devices

19

For Mac users : Step 1: Install the Android Studio

Step2 : Open the terminal and type

cd

Step 3: Type below mentioned command changing the userName:

export PATH=“/Users/{user_name}/Library/Android/sdk/platform-tools”:$PATH
0
17

On MacOS Big Sur do the following:

Open config file:

nano ~/.zshrc

Add paths to PATH variable:

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

close file and save changes. Then in terminal write:

source ~/.zshrc

And then you'll be able to run:

adb devices
adb kill-server
16

cd sdk/platform-tools/ and then use ./adb devices instead

1
  • 3
    I have to be inside /Users/ashokr/Library/Android/sdk/platform-tools and then it works.
    – Ashok R
    Commented Feb 9, 2018 at 19:57
14

This solution is for Mac:

Considering you have already downloaded SDK platform tools & trying to set adb path:

If you want to check the SDK is available or not, just check it by following this path:
User > Library (Hidden folder) > Android > sdk > platform-tools > adb

SDK PATH IMAGE

To set the PATH for the adb command on a macOS system, firstly need to edit your shell configuration file. The default shell on macOS is Bash or Zash.
If you're using Bash, so you will need to edit the ~/.bash_profile file otherwise edit ~/.zprofile in your home directory.

Here's how to do it:

By Terminal:

  1. Open a terminal window and enter the following command:
nano ~/.bash_profile

or

nano ~/.zprofile

This will open the ~/.bash_profile or ~/.zprofile file in the Nano text editor.

  1. Add the following line to the file:
export PATH=~/Library/Android/sdk/tools:$PATH
export PATH=~/Library/Android/sdk/platform-tools:$PATH

Press Ctrl+X to exit the Nano editor, then press Y to save the changes and Enter to confirm the filename.

  1. Run the following command to reload your shell configuration:
source ~/.bash_profile

or

source ~/.zprofile

After you have set the PATH for adb, you should be able to run the adb command from any terminal window.


By Manual:

  1. Go to the Home directory & tap command + shift + . (To show the hidden files)
    View IMAGE
  2. Search file ~/.bash_profile or ~/.zprofile & open it.
    View IMAGE
  3. Add required path & save it.
    View IMAGE
export PATH=~/Library/Android/sdk/tools:$PATH
export PATH=~/Library/Android/sdk/platform-tools:$PATH
  1. Run the following command to reload your shell configuration:
source ~/.bash_profile

or

source ~/.zprofile

After you have set the PATH for adb, you should be able to run the adb command from any terminal window.

1
  • 1
    This worked for bash_profile thank you
    – Vasanth
    Commented Apr 18 at 7:26
9

If you using zsh then you need do the add the following to your .zshrc

Steps: Step 1: Open your .zshrc profile

open -e .zshrc

Step 2: Add the following to the file

export PATH=$PATH:/Users/${YourUser}/Library/Android/sdk/platform-tools
export ANDROID_HOME=/Users/${YourUser}/Library/Android/sdk

Step 3: Save the file and close. Step 4: Reload the .zshrc

source .zshrc

Step 5: Check the devices connected

adb devices
7

if you are using Android Studio in MAC OS X , you could exec the following command in your terminal app:

echo 'alias adb="/Applications/Android\ Studio.app/sdk/platform-tools/adb"' >> .bashrc
exec $SHELL

and next:

adb devices

and you should be showing a list with your android devices connected via USB cable in your MAC, for example something like this:

* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
deb7bed5        device
2
  • 1
    Can you just clarify what the exec $SHELL line does exactly? Newb here, never used that in a terminal before! :) Commented Oct 13, 2014 at 20:46
  • I run this command, because after edit the '.basrc' is necessary that restart the command line, and with this command you can restart without to close the terminal window
    – trejo08
    Commented Oct 15, 2014 at 21:00
7

MAC Solution.

cd /Users/<user>/Library/Android/sdk/platform-tools
./adb devices
6

For macOS Users Updated to MacOs Catalina,

~/.bash_profile changed to ~/.zshrc

So ,to run adb command and all other commands already exported to ~/.bash_profile easy walkaround is to export bash_profile to zshrc

To do that,

1) Navigate to the home directory in finder

2) I used Cmd + Shift + . to show the hidden files in Finder

3) Create .zshrc file if already not exist

4) Add line "source ~/.bash_profile" without quotes

5) Save

6) Quit and open terminal

start using adb devices

1
5

Here's a detailed manual:
http://codexpi.com/add-android-adb-path-mac-os-x-mavericks/

To sum this up:

  1. Create and open the bash_profile file

    touch .bash_profile
    open -e .bash_profile

  2. Add the path of the platform-tools folder (within the Android SDK)

    export PATH="$PATH:/Users/USERNAME/PATH TO ANDROID SDK/platform-tools/

  3. Run the command . .bash_profile to update (no need to restart the terminal)

1
  • remove " after PATH=
    – divonas
    Commented Sep 12, 2019 at 10:52
5

If you are using ZSH and have Android Studio 1.3: 1. Open .zshrc file (Located in your home directory, file is hidden so make sure you can see hidden files) 2. Add this line at the end: alias adb="/Users/kamil/Library/Android/sdk/platform-tools/adb" 3. Quit terminal 4. Open terminal and type in adb devices 5. If it worked it will give you list of all connected devices

5

Mac OS Open Terminal

touch ~/.bash_profile; open ~/.bash_profile

Copy and paste:

export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools

command + S for save.

1
  • Still getting zsh: command not found: adb after opening a new terminal window. EDIT: I just had to follow these steps afterwards: [ stackoverflow.com/a/59243688/3511695 ]
    – velkoon
    Commented Sep 28, 2021 at 21:36
4

If you are setting the path in Catalina use below command one after another in the terminal. It's working fine for me.

export ANDROID_HOME=/Users/$USER/Library/Android/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

source ~/.bash_profile
0
4

Download Android Platform Tools for macOS from:

https://developer.android.com/studio/releases/platform-tools

Extract to your somewhere e.g ~/installs/platform-tools

Add that folder to path by running:

echo 'export PATH=$PATH:~/installs/platform-tools' >> ~/.zshrc

Either restart terminal or run:

source ~/.zshrc

Assuming that you are using zsh.

3

Commenting with some updated information from 2018.

Executable Binaries for Platform tools are made available for mac by Android here: https://developer.android.com/studio/releases/platform-tools.html

Download these to your mac. Place them in a directory e.g. I placed in ~/Software/platform-tools

If you have root access, the easiest way I have found on a mac is to add your directories to the list in /etc/paths. I like this way because after a few additions the $PATH starts to look too messy and hard to read, the /etc/pathshas everything in separate line, clean and organized. The downside is that you require root access.

$ cat /etc/paths  # check contents of the file
$ sudo nano /etc/paths

Paste the full path of your platform-tools directory (something like /Users/GodZilla/Software/platform-tools/adb) at the end of this list and save. Quit and Open terminal again and check if it sees your platform-tools directory.

$ which adb
/Users/GodZilla/Software/platform-tools/adb
$ which fastboot
/Users/GodZilla/Software/platform-tools/fastboot

If you don't have root access, just add the platform-tools directory to $PATH in your .bash_profile (or .zshenv if you use zsh) as other users have suggested.

2

This totally worked for me, after dickering around for a while after installing Android Studio:

  1. Make sure you have the .bash_profile file. This should be in your [username] directory.

  2. From whatever directory you are on, type this:

    echo "export PATH=\$PATH:/Users/${USER}/Library/Android/sdk/platform-tools/" >> ~/.bash_profile
    

Now, usually you will have this exact path, but if not, then use whatever path you have the platform-tools folder

  1. From the directory where your .bash_profile resides, type this:

    . .bash_profile
    
  2. Now type adb devices. You should see a "List of devices attached" response. Now you do not have to go to the platform-tools directory each and every time to type in the more cryptic command like, ./adb devices!!!

1
  • it's a little easier to read for a newbie I think. maybe it could be added to the other? Commented Dec 8, 2016 at 22:53
2

In my case, I installed Android studio, and have some apps (rust lang) that changes the ~/.profile, and adding adb to ~/.bash_profile made the rust un-executable, so I made the changes to the ~/.profile only, as:

$ echo 'PATH=$PATH:$HOME/Library/Android/sdk/platform-tools/' >> ~/.profile
$ source ~/.profile
$ adb --version
Android Debug Bridge version 1.0.41
Version 29.0.4-5871666
Installed as /Users/hasan/Library/Android/sdk/platform-tools/adb
1

In my case : I did the following (on a mac) :

  1. backed up the ".bash_profile" and ".profile"
  2. cleared all the android related paths.
  3. created the new paths but this time around, I dragged the respective folders : { /.../sdk, /.../tools, /.../platform-tools } into the terminal. I did this for both ".bash_profile" and ".profile".
  4. Then after successfully saving the files each. I restarted the terminal just to be sure about the modifications I made.
  5. I then went on to test if adb was responding now ... by typing : (in terminal) adb devices
  6. I still had no luck (my devices) where not showing, then I restarted the adb, still.
  7. I went on to do "android update adb" . This just killed and restarted the adb
  8. I tried again still the devices wasnt showing.
  9. I totally backed up my android device and resetted the whole phone back to factory default, went over to activate the device for development and allow for usb debugging in its settings > applications.

******** WORKED LIKE A CHARM ********

I tried again with the command "adb devices" and everything was back to normal the device was visible.

All the best. Just dont give up. It took me a lot of troubleshooting. All the best of luck.

1

Considering you have already downloaded SDK platform tools.

This command will set ADB locally. So if you close the terminal and open it again, ADB commands won't work until you run this command again.

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

These commands will set ADB globally. So once you run these commands no need to set them again next time.

echo 'export PATH=$PATH:~/Library/Android/sdk/platform-tools/' >> ~/.bash_profile

source ~/.bash_profile
0

If you are using zsh terminal do the following:

1) Open .zprofile file with the editor of your choice like "open -a xcode ~/.zprofile"

2) Add new PATH or Env Variable in .zprofile Save the file and quit the editor.

3) Execute your .zprofile to update your PATH: source ~/.zprofile

0

Add environment variable for Android Home Targetting Platform Tools

echo 'export ANDROID_HOME=/Users/$USER/Library/Android/sdk' >> ~/.bash_profile

echo 'export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools' >> ~/.bash_profile

Restart Bash

source ~/.bash_profile

Now Check adb

Simply type

adb

on terminal

Not the answer you're looking for? Browse other questions tagged or ask your own question.