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:
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
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
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"
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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…