Reputation: 8328
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.
Upvotes: 384
Views: 480647
Reputation: 38652
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:
$HOME
is your user's home directory) one of the following (or verify via Configure > SDK Manager in the Android Studio startup screen):$HOME/Android/Sdk
$HOME/Library/Android/sdk
$HOME/.bashrc
$HOME/.bash_profile
(Zsh became the default shell in macOS since Catalina)$HOME/.zshrc
platform-tools
if it differs:# macOS
export ANDROID_HOME="$HOME/Library/Android/sdk"
# Linux
export ANDROID_HOME="$HOME/Android/sdk"
# macOS and Linux
export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH"
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.
Upvotes: 693
Reputation: 634
The only thing that worked for me was opening the terminal settings and changing the shell path from /bin/bash to /bin/zsh
Upvotes: 0
Reputation: 2382
As @Loren.A mentioned in comment latest version of brew does not support cast
. So one can simply use:
brew install android-platform-tools
Simply install adb with brew
brew cask install android-platform-tools
Check if adb is installed
adb devices
Upvotes: 38
Reputation: 4055
For zsh
users. Add alias adb='/Users/$USER/Library/Android/sdk/platform-tools/adb'
to .zshrc
file.
Then run source ~/.zshrc
command
Upvotes: 280
Reputation: 1439
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
Upvotes: 62
Reputation: 13292
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
Upvotes: 47
Reputation: 4495
run command in terminal nano $HOME/.zshrc
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
Press Ctrl + X to save file in editor,Enter Yes or No and hit Enter key
Run source ~/.zshrc
Check adb in terminal, run adb
Upvotes: 161
Reputation: 1
Follow steps below
In some cases, you may need to run source .bash_profile every time you open cmd to run adb commands
Upvotes: 0
Reputation: 20221
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
Upvotes: 21
Reputation: 1188
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
Upvotes: 52
Reputation: 1501
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
Upvotes: 7
Reputation: 3083
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.
Upvotes: 3
Reputation: 1
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.!
Upvotes: 0
Reputation: 2060
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.
Upvotes: 6
Reputation: 5304
For Mac, Android Studio 3.6.1, I added this to .bash_profile
export PATH="~/Library/Android/sdk/platform-tools/platform-tools":$PATH
Upvotes: 2
Reputation: 1334
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.
Upvotes: 1
Reputation: 4636
Or the alternative solution could be
If the SDK is there then run this command. ./platform-tools/adb install your-apk-location
From there you can generate the APK file That's the only sample to check if adb command is there
Upvotes: 1
Reputation: 5889
Pasting this command in terminal solves the issue in most cases:
~/.bash_profile
using vi ~/.bash_profile
and add this line to it: export PATH="~/Library/Android/sdk/platform-tools":$PATHHowever, if not, continue reading.
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.
Path to this folder varies by installation scenario, but common ones are:
If you have installed Android Studio somewhere else, determine its location by going to:
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
Upvotes: 68
Reputation: 1533
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
Upvotes: 13
Reputation: 4162
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
Upvotes: 37
Reputation: 17606
In addition to slhck, this is what worked for me (mac).
To check where your sdk is located.
File -> Project Structure -> Sdk location
Copy the path.
Create the hidden .bash_profile
in your home.
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
. ~/.bash_profile
SO post on how to find adb devices
Upvotes: 77
Reputation: 1
It's working fine..
brew install android-sdk
Later on:
android update sdk --no-ui --filter 'platform-tools'
Upvotes: -13