354

I have installed Android SDK and Eclipse on my Mac system. I am able to program using Eclipse and have created few sample applications. But I am still not able to access adb through the terminal window. I have tried following command in terminal:

$ pwd
/Users/espireinfolabs/Desktop/soft/android-sdk-mac_x86/platform-tools

$ ls
NOTICE.txt  dexdump     llvm-rs-cc-2
aapt        dx          llvm-rs-cc.txt
adb         lib         source.properties
aidl        llvm-rs-cc

$ adb --help
-bash: adb: command not found

I have also added the ls output so that you know in which window I am.

21 Answers 21

681

The problem is: adb is not in your PATH. This is where the shell looks for executables. You can check your current PATH with echo $PATH.

Bash will first try to look for a binary called adb in your Path, and not in the current directory. Therefore, if you are currently in the platform-tools directory, just call

./adb --help

The dot is your current directory, and this tells Bash to use adb from there.

But actually, you should add platform-tools to your PATH, as well as some other tools that the Android SDK comes with. This is how you do it:

  1. Find out where you installed the Android SDK. This might be (where $HOME is your user's home directory) one of the following (or verify via Configure > SDK Manager in the Android Studio startup screen):

    • Linux: $HOME/Android/Sdk
    • macOS: $HOME/Library/Android/sdk
  2. Find out which shell profile to edit, depending on which file is used:

    • Linux: typically $HOME/.bashrc
    • macOS: typically $HOME/.bash_profile
    • With Zsh: $HOME/.zshrc
  3. Open the shell profile from step two, and at the bottom of the file, add the following lines. Make sure to replace the path with the one where you installed platform-tools if it differs:

    export ANDROID_HOME="$HOME/Android/Sdk"
    export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH"
    
  4. Save the profile file, then, re-start the terminal or run source ~/.bashrc (or whatever you just modified).

Note that setting ANDROID_HOME is required for some third party frameworks, so it does not hurt to add it.

19
  • 11
    type "source .bash_profile" or open a new terminal tab after adding that line to start using it inmediately
    – Maragues
    Jan 9, 2013 at 14:56
  • 5
    To edit the ~/.profile file in TextEdit, simply enter open ~/.profile in Terminal. Jul 9, 2013 at 21:33
  • 1
    Lastly, what worked for me was NOT having the /:$PATH at the end of the line. Jul 9, 2013 at 21:55
  • 1
    @marciokoko You need to put the path into quotes, e.g. export PATH="/Applications/Android Studio.app/sdk/platform-tools":$PATH. Otherwise the space will be treated as a separator.
    – slhck
    Jan 31, 2014 at 14:31
  • 15
    In more recent Android Studio releases: "/Users/<user>/Library/Android/sdk/platform-tools" so it will be the following: export PATH="/Users/myuser/Library/Android/sdk/platform-tools":$PATH
    – eb80
    Jan 10, 2015 at 15:43
227

For zsh users. Add alias adb='/Users/$USER/Library/Android/sdk/platform-tools/adb' to .zshrc file.

Then run source ~/.zshrc command

2
  • 7
    This worked for me. Don't forget to source ~/.zshrc for the changes to take effect! Feb 10, 2019 at 22:33
  • 2
    You can use "$USER" instead of <yourUserName>, to make this more dynamic. Apr 11, 2022 at 2:37
142
  1. run command in terminal nano $HOME/.zshrc

  2. Must include next lines:

    export PATH=$PATH:~/Library/Android/sdk/platform-tools
    export ANDROID_HOME=~/Library/Android/sdk
    export PATH="$HOME/.bin:$PATH"
    export PATH="~/Library/Android/sdk/platform-tools":$PATH
    
  3. Press Ctrl + X to save file in editor,Enter Yes or No and hit Enter key

  4. Run source ~/.zshrc

  5. Check adb in terminal, run adb

6
  • 3
    step 3 Press Control + X to save file in editor,Enter Yes or No and hit Enter key Apr 12, 2021 at 10:27
  • 1
    I had to close and start a new terminal after for this to work Oct 22, 2021 at 10:04
  • Worked for me in MacOS Monterey Version 12.2.1 Feb 19, 2022 at 23:45
  • Finalllly, thanks mate worked on Big Sur 11.6.4 Apr 14, 2022 at 10:15
  • Ln 1 looks like doing the same thing with Ln 4. What is the point? What is the purpose of Ln 3 though?
    – bfrguci
    May 4, 2022 at 22:44
76

In addition to slhck, this is what worked for me (mac).

To check where your sdk is located.

  1. Open Android studio and go to:

File -> Project Structure -> Sdk location

  1. Copy the path.

  2. Create the hidden .bash_profile in your home.

  3. (open it with vim, or open -e) with the following:

export PATH=/Users/<Your session name>/Library/Android/sdk/platform-tools:/Users/<Your session name>/Library/Android/sdk/tools:$PATH

  1. Then simply use this in your terminal: . ~/.bash_profile

SO post on how to find adb devices

0
67

Quick Answer

Pasting this command in terminal solves the issue in most cases:

** For Current Terminal Session:

  • (in macOS) export PATH="~/Library/Android/sdk/platform-tools":$PATH
  • (in Windows) i will update asap

** Permanently:

  • (in macOS) edit the ~/.bash_profile using vi ~/.bash_profile and add this line to it: export PATH="~/Library/Android/sdk/platform-tools":$PATH

However, if not, continue reading.


Detailed Answer

Android Debug Bridge, or adb for short, is usually located in Platform Tools and comes with Android SDK, You simply need to add its location to system path. So system knows about it, and can use it if necessary.

Find ADB's Location

Path to this folder varies by installation scenario, but common ones are:


  • If you have installed Android Studio, path to ADB would be: (Most Common)
    • (in macOS) ~/Library/Android/sdk/platform-tools
    • (in Windows) i will update asap

  • If you have installed Android Studio somewhere else, determine its location by going to:

    • (in macOS) Android Studio > Preferences > Appearance And Behavior > System Settings > Android SDK and pay attention to the box that says: Android SDK Location
    • (in Windows) i will update asap

  • However Android SDK could be Installed without Android studio, in this case your path might be different, and depends on your installation.

Add it to System Path

When you have determined ADB's location, add it to system, follow this syntax and type it in terminal:

  • (in macOS)

    export PATH="your/path/to/adb/here":$PATH

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

3
  • "Permanently" worked. Long story short for it: 1. vi ~/.bash_profile 2. export PATH="~/Library/Android/sdk/platform-tools":$PATH 3. :x Oct 1, 2018 at 13:01
  • 1
    vi something else use the console editor for opening the file, you can also use open ~/.bash_profile
    – cutiko
    Jan 22, 2019 at 19:44
  • Thanks for the exact answer. Other's answers are very much confusing. May 10, 2021 at 13:15
51

I don't know how did you install the android SDK. But in Mac OS, what really worked for me is to reinstall it using brew. All problems solved in a row.

brew install --cask android-sdk

Later on:

android update sdk --no-ui --filter 'platform-tools'

Like a charm

6
50

enter image description hereThis is how it worked for me

first I find my platform-tools than I was using zshrc instead of bash_profile so I run this command first

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

next refresh terminal

source ~/.zshrc

Check if it worked

adb devices

result of this command must be something similar to this if so then it worked.

List of devices attached
emulator-5554   device
1
  • Thanks a lot. So simple just copy / paste!
    – Bob Redity
    Oct 18, 2022 at 17:50
43

If you have installed Android Studio on MAC here is how:

nano ~/.zshrc

or

open ~/.zshrc in VScode

Then edit the file

# Android ADB
export ANDROID_HOME="$HOME/Library/Android/sdk"
export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH"

control + X OR Save file. Restart Terminal and try

> adb
5
  • 3
    clean solution. Worked first time. Sep 2, 2021 at 12:28
  • 1
    Also worked on mac os big sur Oct 19, 2021 at 5:48
  • 1
    working solution
    – Sulfy
    Jun 3, 2022 at 17:04
  • didn't do a thing
    – htafoya
    Jan 3 at 3:33
  • @htafoya are you using bash or zshrc ? if bash then change the above command from .zshrc to .bash_profile
    – Thiago
    Jan 25 at 12:57
36

For me, I ran into this issue after switching over from bash to zsh so I could get my console to look all awesome fantastic-ish with Hyper and the snazzy theme. I was trying to run my react-native application using react-native run-android and running into the op's issue. Adding the following into my ~.zshrc file solved the issue for me:

export ANDROID_HOME=~/Library/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools
0
29

UPDATE

As @Loren.A mentioned in comment latest version of brew does not support cast. So one can simply use:

brew install android-platform-tools


  1. Simply install adb with brew

    brew cask install android-platform-tools

  2. Check if adb is installed

    adb devices

2
  • 1
    This appears to be the easiest solution. The current version of brew doesn't use cask so the command that worked for me is brew install android-platform-tools
    – Loren.A
    Jul 11, 2022 at 15:24
  • now you only need to install homebrew, and probably upgrade python
    – htafoya
    Jan 3 at 3:30
21

If you are using the Mac with the M1 chip add the below export command to the zshrc file using the nano command, if that file is not present the nano command will create it for you so run

nano ~/.zshrc

paste this path in that file without any modification

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

hit ctrl-x and then Hit y to save the changes and the hit return Key to close it without renaming the file.

then run

source ~/.zshrc

to refresh the .zshrc file

and then try runnning

adb

it should give you the desired output

13

If you are using zsh on an OS X, you have to edit the zshrc file.

Use vim or your favorite text editor to open zshrc file:

vim ~/.zshrc

Paste the path to adb in this file:

export PATH="/Users/{$USER}/Library/Android/sdk/platform-tools":$PATH
2
  • 1
    nano ~/.zshrc export PATH="/Users/{$USER}/Library/Android/sdk/platform-tools":$PATH
    – Guy West
    Jan 6, 2020 at 10:03
  • For me I had to use my username i.e. sonusourav in place of {$USER} probably because USER was not defined Jan 27, 2022 at 14:52
6

For Mac OS Catalina or Mojave

Enter command to open nano editor

nano $HOME/.zshrc

Set PATH variable, means append more path as shown here

FLUTTER_HOME="/Users/pankaj/Library/Android/flutter-sdk/flutter/bin"
DART_HOME="/Users/pankaj/Library/Android/flutter-sdk/flutter/bin/cache/dart-sdk/bin"
ANDROID_SDK_HOME="/Users/pankaj/Library/Android/sdk"
ANDROID_ADB_HOME="/Users/pankaj/Library/Android/sdk/platform-tools"

PATH="$PATH:$FLUTTER_HOME"
PATH="$PATH:$DART_HOME"
PATH="$PATH:$ANDROID_SDK_HOME"
PATH="$PATH:$ANDROID_ADB_HOME"

Now press Command + X to save file in editor,Enter Yes or No and hit Enter key.

2
6

This worked for me on my MAC - 2020

Go to directory containing adb:

cd ~/Library/Android/sdk/platform-tools/

Run adb command to list all services

./adb shell dumpsys activity services
1
  • Short and clean solution worked in first attempt Mar 6, 2022 at 16:56
3

I couldn't get the stupid path working so I created an alias for abd

alias abd ="~/Library/Android/sdk/platform-tools/adb"

works fine.

2

For Mac, Android Studio 3.6.1, I added this to .bash_profile

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

1

Or the alternative solution could be

  1. Make sure you already install for android SDK. Usually it is located under /Users/your-user-name/Library/Android/sdk
  2. If the SDK is there then run this command. ./platform-tools/adb install your-apk-location

  3. From there you can generate the APK file That's the only sample to check if adb command is there

1
  • Thanks. It worked but I had to add sdk directory in the path for 2nd step: ./Library/Android/sdk/platform-tools/adb install ~/Downloads/apk-release.apk Nov 18, 2018 at 10:26
1

For some reason when installed Android Studio 3.6.1 the adb file was actually in $ANDROID_HOME/platform-tools/platform-tools. not sure if this is a bug with my installation or what but this fixed it for me.

0

For Mac Os the default shell has moved on to "zsh" from "bash" as of Mojave and later releases, so for all the Mac users I would suggest go with the creating ".zshrc" file. "adb" runs as it is intended to be. Thanks @slhck for your info.!

0

Follow steps below

  • Open bash_profile using open -e .bash_profile
  • write export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH"
  • close bash_profile file
  • run source .bash_profile
  • Done run your adb command now !!

In some cases, you may need to run source .bash_profile every time you open cmd to run adb commands

-13

It's working fine..

brew install android-sdk

Later on:

android update sdk --no-ui --filter 'platform-tools'
2
  • 4
    Slightly similar at my answer don't you think?
    – eMarine
    Oct 23, 2016 at 4:17
  • I couldn't figure it out because you never mentioned "Like a charm"
    – quemeful
    Nov 22, 2016 at 14:40

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