Trying to add adb to PATH variable OSX
Why are you trying to run "./adb"? That skips the path variable entirely and only looks for "adb" in the current directory. Try running "adb" instead.
Edit: your path looks wrong. You say you get
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Libs/android-sdk-mac_x86/tools:/Libs/android-sdk-mac_x86/platform-tools
You're missing the /Users/simon part.
Also note that if you have both .profile and .bash_profile files, only the latter gets executed.
Set up adb on Mac OS X
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.
Install homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Install adb
brew install android-platform-tools
or try a cask install depending on your settings:
brew install --cask android-platform-tools
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.
Delete your old installation (optional)
rm -rf ~/.android-sdk-macosx/
Navigate to https://developer.android.com/studio/releases/platform-tools.html and click on the
SDK Platform-Tools for Mac
link.Go to your Downloads folder
cd ~/Downloads/
Unzip the tools you downloaded
unzip platform-tools-latest*.zip
Move them somewhere you won't accidentally delete them
mkdir ~/.android-sdk-macosx
mv platform-tools/ ~/.android-sdk-macosx/platform-toolsAdd
platform-tools
to your pathecho 'export PATH=$PATH:~/.android-sdk-macosx/platform-tools/' >> ~/.bash_profile
Refresh your bash profile (or restart your terminal app)
source ~/.bash_profile
Start using adb
adb devices
Option 3 - If you already have Android Studio installed
Add
platform-tools
to your pathecho 'export ANDROID_HOME=/Users/$USER/Library/Android/sdk' >> ~/.bash_profile
echo 'export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools' >> ~/.bash_profileRefresh your bash profile (or restart your terminal app)
source ~/.bash_profile
Start using adb
adb devices
Option 4 - MacPorts
Install the Android SDK:
sudo port install android
Run the SDK manager:
sh /opt/local/share/java/android-sdk-macosx/tools/android
Uncheck everything but
Android SDK Platform-tools
(optional)Install the packages, accepting licenses. Close the SDK Manager.
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
Refresh your bash profile (or restart your terminal/shell):
source ~/.bash_profile
Start using adb:
adb devices
Option 5 - Manually (with SDK Manager)
Delete your old installation (optional)
rm -rf ~/.android-sdk-macosx/
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.
Go to your Downloads folder
cd ~/Downloads/
Unzip the tools you downloaded
unzip tools_r*-macosx.zip
Move them somewhere you won't accidentally delete them
mkdir ~/.android-sdk-macosx
mv tools/ ~/.android-sdk-macosx/toolsRun the SDK Manager
sh ~/.android-sdk-macosx/tools/android
Uncheck everything but
Android SDK Platform-tools
(optional)
- Click
Install Packages
, accept licenses, clickInstall
. Close the SDK Manager window.
Add
platform-tools
to your pathecho 'export PATH=$PATH:~/.android-sdk-macosx/platform-tools/' >> ~/.bash_profile
Refresh your bash profile (or restart your terminal app)
source ~/.bash_profile
Start using adb
adb devices
Not able to access adb in OS X through Terminal, command not found
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
- Linux:
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
- Linux: typically
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.
Installing ADB on macOS
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.
Install the homebrew package manager
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Install adb
brew install android-platform-tools
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.
Delete your old installation (optional)
rm -rf ~/.android-sdk-macosx/
Navigate to https://developer.android.com/studio/releases/platform-tools.html and click on the
SDK Platform-Tools for Mac
link.Go to your Downloads folder
cd ~/Downloads/
Unzip the tools you downloaded
unzip platform-tools-latest*.zip
Move them somewhere you won't accidentally delete them
mkdir ~/.android-sdk-macosx
mv platform-tools/ ~/.android-sdk-macosx/platform-toolsAdd
platform-tools
to your pathecho 'export PATH=$PATH:~/.android-sdk-macosx/platform-tools/' >> ~/.bash_profile
Refresh your bash profile (or restart your terminal app)
source ~/.bash_profile
Start using adb
adb devices
Option 3 - Manually (with SDK Manager)
Delete your old installation (optional)
rm -rf ~/.android-sdk-macosx/
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.
Go to your Downloads folder
cd ~/Downloads/
Unzip the tools you downloaded
unzip tools_r*-macosx.zip
Move them somewhere you won't accidentally delete them
mkdir ~/.android-sdk-macosx
mv tools/ ~/.android-sdk-macosx/toolsRun the SDK Manager
sh ~/.android-sdk-macosx/tools/android
Uncheck everything but
Android SDK Platform-tools
(optional)
- Click
Install Packages
, accept licenses, clickInstall
. Close the SDK Manager window.
Add
platform-tools
to your pathecho 'export PATH=$PATH:~/.android-sdk-macosx/platform-tools/' >> ~/.bash_profile
Refresh your bash profile (or restart your terminal app)
source ~/.bash_profile
Start using adb
adb devices
How do i add android tools to my path on mac?
I just set up a Mac mini for work using the following steps, so I can guarantee this works with a fresh install.
1) Install Android Studio. (Standard is fine, Custom if you want to)
2) Launch Android Studio
3) From the Welcome Screen, click Configure (bottom right corner) > SDK Manager
4) Double check that you have the latest platform tools and tools installed in the SDK Tools tab.
At this point, you will have installed everything related to the android sdk, including the tools, in the default location of /Users/your-user-name/Library/Android/sdk
5) Create a .bash_profile file if you don't already have one at /Users/your-user-name
6) Add the following lines to it: (replace my username with yours)
export PATH=$PATH:/Users/chris.w.newman/Library/Android/sdk/platform-tools
export PATH=$PATH:/Users/chris.w.newman/Library/Android/sdk/tools
export ANDROID_HOME=/Users/chris.w.newman/Library/Android/sdk
By adding it to your .bash_profile, these lines will run every time you use a shell. So you don't have to worry about them ever again.
To test that everything works correctly, try the following 'which' commands from a new shell:
which adb
which android
Since these are added to the path, you should see their file path printed in the shell.
How do I properly set my PATH variable in my .bash_profile? to use adb on Lion?
You have a semicolon instead of colon between the two folder paths..
bash: adb: command not found error on Mac
Go to your Library folder on your mac.
~/Library/Android/sdk/build-tools/VERSION/
ADB is part of your Android studio installation. It should be located in above path.
zsh: command not found: adb in mac OS
export ANDROID_HOME=/Users/aanshu/Library/Android/sdk/platform-tools/adb
...is obviously wrong. It should instead be:
export ANDROID_HOME=/Users/aanshu/Library/Android/sdk
...because it provides a base to which the subsequent lines append.
adb: command not found ( from within the platform-tools directory ) on Mac OS X Yosemite
Since "platform-tools" is probably not part of the system path, you should try running: "./adb" instead of "adb" from the platform-tools location. Or use the full path to it.
Using "." would indicate that you are trying to launch adb from the current directory
Related Topics
Opening Webview Not in New Browser
How to Get HTML Source Code from Url in Android
Execute Task Before Android Gradle Build
How to Find Intent Source in Android
Change Background of Progressdialog
Register to Be Default App for Custom File Type
How to Rename a File on Sdcard with Android Application
Set Permission for Getting User's Email Id from Facebook Login
Installation Error: Install_Failed_Older_Sdk
How to Completely Kill/Remove/Delete/Stop an Asynctask
Cannot Find Symbol Databindingcomponent on Android Studio 3.2 Canary 16 Kotlin Project
Android Beginner Difference Between Padding and Margin
How to Change Package Name in Android Studio
Android Circular Determinate Progressbar
Detect If an App Is Installed from Play Store