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.
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.