I need to run an adb forward command before I could use the ezkeyboard application which allows user to type on the phone using browser.
When I run adb forward tcp:8080 tcp:8080 command I get the adb command not found error message.
I can run android command from terminal. Why adb is not working?
In my case with Android Studio 1.1.0 path was this
/Users/<username>/Library/Android/sdk/platform-tools
Add the following to ~/.bash_profile
export PATH=~/Library/Android/sdk/tools:$PATH
export PATH=~/Library/Android/sdk/platform-tools:$PATH
Then run
$ source ~/.bash_profile
to load a profile in a current terminal session, or just reopen a terminal
If you are using more modern Z Shell instead of Bash, put it in ~/.zprofile instead.
Is adb installed? To check, run the following command in Terminal:
~/Library/Android/sdk/platform-tools/adb
If that prints output, skip these following install steps and go straight to the final Terminal command I list:
Launch Android Studio
Launch SDK Manager via Tools -> Android -> SDK Manager
Check Android SDK Platform-Tools
Run the following command on your Mac and restart your Terminal session:
echo export "PATH=~/Library/Android/sdk/platform-tools:$PATH" >> ~/.bash_profile
Note: If you've switched to zsh, the above command should use .zshenv rather than .bash_profile
Make sure adb is in your user's $PATH variable.
or
You can try to locate it with whereis and run it with ./adb
I am using Mac 10.11.1 and using android studio 1.5,
I have my adb
"/Users/user-name/Library/Android/sdk/platform-tools"
Now edit you bash_profile
emacs ~/.bash_profile
Add this line to your bash_profile, and replace the user-name with your username
export PATH="$PATH:/Users/user-name/Library/Android/sdk/platform-tools"
save and close.
Run this command to reload your bash_profile
source ~/.bash_profile
From the file android-sdks/tools/adb_has_moved.txt:
The adb tool has moved to platform-tools/
If you don't see this directory in your SDK, launch the SDK and AVD
Manager (execute the android tool) and install "Android SDK
Platform-tools"
Please also update your PATH environment variable to include the
platform-tools/ directory, so you can execute adb from any location.
so on UNIX do something like:
export PATH=$PATH:~/android-sdks/platform-tools
This is the easiest way and will provide automatic updates.
install homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install adb
brew install --cask android-platform-tools
Start using adb
adb devices
Type the below command in terminal:
nano .bash_profile
And add the following lines (replace USERNAME with your own user name).
export ANDROID_HOME=/Users/USERNAME/Library/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
Close the text editor, and then enter the command below:
source .bash_profile
If you don't want to edit PATH variable, go to the platform-tools directory where the SDK is installed, and the command is there.
You can use it like this:
Go to the directory where you placed the SDK:
cd /Users/mansour/Library/Developer/Android/sdk/platform-tools
Type the adb command with ./ to use it from the current directory.
./adb tcpip 5555
./adb devices
./adb connect 192.168.XXX.XXX
For mac users with zshrc file (who don't have bash profile).
Go to your user folder and tap cmd + fn + shift + "." (on Mac laptop keyboard !)
Hidden files are visible, open .zhrc file with a Text Editor
Paste this line, don't forget to change the username between braces :
export PATH="$PATH:/Users/{username}/Library/Android/sdk/platform-tools"
you can save and close the .zhrc
Open terminal and reload the file with this :
source ~/.zshrc
Now you can use adb command lines !
Considering you have already downloaded SDK platform tools. These commands are for MAC users.
This command will set ADB locally. So if you close the terminal and open it again, ADB commands won't work until you run this command again.
export PATH=~/Library/Android/sdk/platform-tools:$PATH
These commands will set ADB globally. So once you run these commands no need to set them again next time.
echo 'export PATH=$PATH:~/Library/Android/sdk/platform-tools/' >> ~/.bash_profile
source ~/.bash_profile
Mac users just open /Users/(USERNAME)/.bash_profile this file in a editor.
and add this line to add path.
export PATH="/Users/myuser/Library/Android/sdk/platform-tools":$PATH
this is the default path if you install adb via studio.
and dont forget to change the username in this line.
You need to install adb first,
the new command (in 2021) is:
brew install --cask android-platform-tools
In my case, I was in the platform-tools directory but was using command in the wrong way:
adb install
instead of the right way:
./adb install
On my Mac (OS X 10.8.5) I have adb here:
~/Library/android-sdk-mac_86/platform-tools
So, edit the $PATH in your .bash_profile and source it.
+ The reason is: you are in the wrong directory (means it doesn't contain adb executor).
+ The solution is (step by step):
1) Find where the adb was installed. Depend on what OS you are using.
Mac, it could be in: "~/Library/Android/sdk/platform-tools"
or
Window, it could be in: "%USERPROFILE%\AppData\Local\Android\sdk\platform-tools\".
However, in case you could NOT remember this such long directory, you can quickly find it by the command "find". Try this in your terminal/ command line, "find / -name "platform-tools" 2> /dev/null" (Note: I didn't test in Window yet, but it works with Mac for sure).
*Explain the find command,
Please note there is a space before the "/" character --> only find in User directory not all the computer.
"2> /dev/null" --> ignore find results denied by permission. Try the one without this code, you will understand what I mean.
2) Go to where we installed adb. There are 3 ways mentioned by many people:
Change the PATH global param (which I won't recommend) by: "export PATH=~/Library/Android/sdk/platform-tools" which is the directory you got from above. Note, this command won't print any result, if you want to make sure you changed PATH successfully, call "export | grep PATH" to see what the PATH is.
Add more definition for the PATH global param (which I recommend) by: "export PATH=~/Library/Android/sdk/platform-tools:$PATH" or "export PATH=$PATH:~/Library/Android/sdk/platform-tools"
Go to the path we found above by "cd ~/Library/Android/sdk/platform-tools"
3) Use adb:
If you change or update the PATH, simply call any adb functions, since you added the PATH as a global param. (e.g: "adb devices")
If you go to the PATH by cd command, call adb functions with pre-fix "./ " (e.g: "./ adb devices")
I solved this issue by install adb package. I'm using Ubuntu.
sudo apt install adb
I think this will help to you.
If you are using a mac, try this below command.
source $HOME/.bash_profile
in my case I added the following line in my terminal:
export PATH="/Users/Username/Library/Android/sdk/platform-tools":$PATH
make sure that you replace "username" with YOUR user name.
hit enter then type 'adb' to see if the error is gone. if it is, this is what you should see:
Android Debug Bridge version 1.0.40
...followed by a bunch of commands..and ending with this:
$ADB_TRACE
comma-separated list of debug info to log:
all,adb,sockets,packets,rwx,usb,sync,sysdeps,transport,jdwp
$ADB_VENDOR_KEYS colon-separated list of keys (files or directories)
$ANDROID_SERIAL serial number to connect to (see -s)
$ANDROID_LOG_TAGS tags to be used by logcat (see logcat --help)
if you get that, run npm run android again and it should work..
To avoid rewriting the $PATH variables every time you start a terminal, edit your .bash_profile (for Macs, it's just .profile) file under your home directory (~/), and place the export statement somewhere in the file.
Now every time you start terminal, your $PATH variable will be correctly updated. To update the terminal environment immediately after modifying the profile file, type in:
source ~/.profile
nano /home/user/.bashrc
export ANDROID_HOME=/psth/to/android/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
However, this will not work for su/ sudo. If you need to set system-wide variables, you may want to think about adding them to /etc/profile, /etc/bash.bashrc, or /etc/environment.
ie:
nano /etc/bash.bashrc
export ANDROID_HOME=/psth/to/android/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
This solution is for Mac:
Considering you have already downloaded SDK platform tools & trying to set adb path:
If you want to check the SDK is available or not, just check it by following this path:
User > Library (Hidden folder) > Android > sdk > platform-tools > adb
SDK PATH IMAGE
To set the PATH for the adb command on a macOS system, firstly need to edit your shell configuration file. The default shell on macOS is Bash or Zash.
If you're using Bash, so you will need to edit the ~/.bash_profile file otherwise edit ~/.zprofile in your home directory.
Here's how to do it:
By Terminal:
Open a terminal window and enter the following command:
nano ~/.bash_profile
or
nano ~/.zprofile
This will open the ~/.bash_profile or ~/.zprofile file in the Nano text editor.
Add the following line to the file:
export PATH=~/Library/Android/sdk/tools:$PATH
export PATH=~/Library/Android/sdk/platform-tools:$PATH
Press Ctrl+X to exit the Nano editor, then press Y to save the changes and Enter to confirm the filename.
Run the following command to reload your shell configuration:
source ~/.bash_profile
or
source ~/.zprofile
After you have set the PATH for adb, you should be able to run the adb command from any terminal window.
By Manual:
Go to the Home directory & tap command + shift + . (on Mac system/laptop)
View IMAGE
Search file ~/.bash_profile or ~/.zprofile & open it.
View IMAGE
Add required path & save it.
View IMAGE
export PATH=~/Library/Android/sdk/tools:$PATH
export PATH=~/Library/Android/sdk/platform-tools:$PATH
Run the following command to reload your shell configuration:
source ~/.bash_profile
or
source ~/.zprofile
After you have set the PATH for adb, you should be able to run the adb command from any terminal window.
Make sure you have adb installed
To install it you could run the "sudo apt install adb".
You could also try revoking any USB authorizations on your device and
try connecting with USB debugging enabled.
UNABLE TO LOCATE ADB #SOLVED
Simply Download Sdk platform tools.https://developer.android.com/studio/releases/platform-tools.html
Extract the Downloaded file.
Go to Sdk Manager in Android Studio and copy the link. Go to file Explorer and paste the path for Sdk you copied to view the Sdk files. You will notice that the Adb file is missing, open downloaded file (platform tools) copy contents and replace every content in your Sdk tool file (the file where you noticed adb is missing)and save. You are good to go.
In my case this is the solving of this problem
Make sure you have installed the android SDK. Usually the location of SDK
is located to this location
/Users/your-user/Library/Android/sdk
After that cd to that directory.
Once you are in that directory type this command
./platform-tools/adb install your-location-of apk
if youd dont have adb in folder android-sdk-macosx/platform-tools/ you should install platform tools first. Run android-sdk-macosx/tools/android and Install platform tools from Android SDK manager.
you have to move the adb command to /bin/ folder
in my case:
sudo su
mv /root/Android/Sdk/platform-tools/adb /bin/
If you are using fish:
fish_add_path /Users/<name>/Library/Android/sdk/platform-tools/
Or you can add the same to ~/.config/fish/config.fish
Might need to re start the shell
Add the following command to .zshrc file
Open file in terminal using command -> vi .zshrc
Add the android sdk path - > exportPATH="/Users/<user>/Library/Android/sdk/platform-tools:$PATH"
Close the file by -> Esc + :wq
Related
I spent quite sometime figuring how to set up adb on Mac, so I figure writing how to set it up might be useful to some people. adb is the command line tool to install and run android apps on your phone/emulator
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-tools
Add platform-tools to your path
echo '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 path
echo 'export ANDROID_HOME=/Users/$USER/Library/Android/sdk' >> ~/.bash_profile
echo 'export PATH="$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools"' >> ~/.bash_profile
Refresh 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/tools
Run the SDK Manager
sh ~/.android-sdk-macosx/tools/android
Uncheck everything but Android SDK Platform-tools (optional)
Click Install Packages, accept licenses, click Install. Close the SDK Manager window.
Add platform-tools to your path
echo '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
echo "export PATH=\$PATH:/Users/${USER}/Library/Android/sdk/platform-tools/" >> ~/.bash_profile && source ~/.bash_profile
If you put the android-sdks folder in other directory, replace the path with the directory android-sdks/platform-tools is in
Only for zsh users in iterm2 in macOS
type the following two commands to add the android sdk and platform-tools to your zsh in iterm2 in macOS
echo 'export ANDROID_HOME=/Users/$USER/Library/Android/sdk' >> ~/.zshrc
echo 'export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools' >> ~/.zshrc
After adding the two command to ~/.zshrc you need to source the zsh.
source ~/.zshrc
This Works Flawless....
In terminal Run both commands next to each other
export ANDROID_HOME=/Users/$USER/Library/Android/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
NOTE: Path for adb has changed since Android Studio 1.0.xx
For bash shell, use:
echo 'export PATH=$PATH:'$HOME'/Library/Android/sdk/platform-tools' >> ~/.bash_profile
For tcsh shell, use:
echo 'setenv PATH $PATH\:'$HOME'/Library/Android/sdk/platform-tools' >> ~/.tcshrc
2022 Solution
If you have Android Studio installed already and Terminal isn't picking up ADB, here's a one-liner that should fix it:
sudo ln -s ~/Library/Android/sdk/platform-tools/adb /usr/local/bin
If you are using zsh shell and after trying all this solutions, you still need to set $PATH and $ANDROID_HOME every time you open new terminal instance, then here is your answer:
step 1: in terminal run nano ~/.zshrc
step 2: paste following command at the end of the file
export ANDROID_HOME=~/Library/Android/sdk
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH
step 3: After copying the lines above, to save hit control + X. and to confirm hit Y. It will ask you if you wish to change the file name but don't change the name so directly hit enter
step 4: Restart your terminal and execute the adb command.
Bingo!
Here is a step wise information :
Step-1
Start up Terminal and go to your home folder.
cd ~/
Step-2
Open and edit .bash_profile file
$ open -e .bash_profile
If you don’t have .bash_profile file in your computer path, then create one. Enter below command to create a new file. Once created follow Step-2.
touch .bash_profile
Step-3
Save the below line)
export PATH=${PATH}:/Applications/adt-bundle-mac-x86_64-20140321/sdk/tools
export PATH=${PATH}:/Applications/adt-bundle-mac-x86_64-20140321/sdk/platform-tools
Step-4
Refresh the file using below command
$ source .bash_profile
$ echo $PATH
You should see your android path set in the output now.
Personally I just source my .bashrc in my .bash_profile:
echo 'source ~/.bashrc' >> ~/.bash_profile
So I put it in my .bashrc. And I'm using Android Studio, so it was a different path.
echo 'PATH=$PATH:$HOME/Library/Android/sdk/platform-tools/' >> ~/.bashrc
You may also want the following:
echo 'ANDROID_HOME=$HOME/Library/Android/sdk' >> ~/.bashrc
The simplest way to use adb command on your Mac systems would be to add the path to the platform-tools (where adb lives) into your bash_profile.
Steps to add the adb path:
1. open the bash_profile: This can be done by using the following commands
open ~/.bash_profile
This opens up the bash_profile in an editor.
Locate the platform_tools, usually they are present at the following location: Users/"user_folder"/Library/Android/sdk/platform_tools
Paste the following command in the bash_profile file which opens up:
export PATH=$PATH:/Users/A374375/Library/Android/sdk/platform-tools
Save the file using the command:
source ~/.bash_profile
Check if the path is saved by typing: echo $PATH : You should be able to find the entire path displayed in the output.
Type adb to see if the configuration worked. If you have any devices connected to the machine or any emulators running on your system they would be displayed when you type adb devices
output for adb devices
For Mac users :
Step 1: Install the Android Studio
Step2 : Open the terminal and type
cd
Step 3: Type below mentioned command changing the userName:
export PATH=“/Users/{user_name}/Library/Android/sdk/platform-tools”:$PATH
cd sdk/platform-tools/ and then use ./adb devices instead
On MacOS Big Sur do the following:
Open config file:
nano ~/.zshrc
Add paths to PATH variable:
export PATH=~/Library/Android/sdk/tools:$PATH
export PATH=~/Library/Android/sdk/platform-tools:$PATH
close file and save changes.
Then in terminal write:
source ~/.zshrc
And then you'll be able to run:
adb devices
adb kill-server
If you using zsh then you need do the add the following to your .zshrc
Steps:
Step 1: Open your .zshrc profile
open -e .zshrc
Step 2: Add the following to the file
export PATH=$PATH:/Users/${YourUser}/Library/Android/sdk/platform-tools
export ANDROID_HOME=/Users/${YourUser}/Library/Android/sdk
Step 3: Save the file and close.
Step 4: Reload the .zshrc
source .zshrc
Step 5: Check the devices connected
adb devices
MAC Solution.
cd /Users/<user>/Library/Android/sdk/platform-tools
./adb devices
if you are using Android Studio in MAC OS X , you could exec the following command in your terminal app:
echo 'alias adb="/Applications/Android\ Studio.app/sdk/platform-tools/adb"' >> .bashrc
exec $SHELL
and next:
adb devices
and you should be showing a list with your android devices connected via USB cable in your MAC, for example something like this:
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
deb7bed5 device
For macOS Users Updated to MacOs Catalina,
~/.bash_profile changed to ~/.zshrc
So ,to run adb command and all other commands already exported to ~/.bash_profile easy walkaround is to export bash_profile to zshrc
To do that,
1) Navigate to the home directory in finder
2) I used Cmd + Shift + . to show the hidden files in Finder
3) Create .zshrc file if already not exist
4) Add line "source ~/.bash_profile" without quotes
5) Save
6) Quit and open terminal
start using adb devices
Here's a detailed manual:
http://codexpi.com/add-android-adb-path-mac-os-x-mavericks/
To sum this up:
Create and open the bash_profile file
touch .bash_profile
open -e .bash_profile
Add the path of the platform-tools folder (within the Android SDK)
export PATH="$PATH:/Users/USERNAME/PATH TO ANDROID SDK/platform-tools/
Run the command . .bash_profile to update (no need to restart the terminal)
If you are using ZSH and have Android Studio 1.3:
1. Open .zshrc file (Located in your home directory, file is hidden so make sure you can see hidden files)
2. Add this line at the end: alias adb="/Users/kamil/Library/Android/sdk/platform-tools/adb"
3. Quit terminal
4. Open terminal and type in adb devices
5. If it worked it will give you list of all connected devices
Mac OS
Open Terminal
touch ~/.bash_profile; open ~/.bash_profile
Copy and paste:
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
command + S for save.
If you are setting the path in Catalina use below command one after another in the terminal. It's working fine for me.
export ANDROID_HOME=/Users/$USER/Library/Android/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
source ~/.bash_profile
Commenting with some updated information from 2018.
Executable Binaries for Platform tools are made available for mac by Android here: https://developer.android.com/studio/releases/platform-tools.html
Download these to your mac. Place them in a directory e.g. I placed in ~/Software/platform-tools
If you have root access, the easiest way I have found on a mac is to add your directories to the list in /etc/paths. I like this way because after a few additions the $PATH starts to look too messy and hard to read, the /etc/pathshas everything in separate line, clean and organized. The downside is that you require root access.
$ cat /etc/paths # check contents of the file
$ sudo nano /etc/paths
Paste the full path of your platform-tools directory (something like /Users/GodZilla/Software/platform-tools/adb) at the end of this list and save. Quit and Open terminal again and check if it sees your platform-tools directory.
$ which adb
/Users/GodZilla/Software/platform-tools/adb
$ which fastboot
/Users/GodZilla/Software/platform-tools/fastboot
If you don't have root access, just add the platform-tools directory to $PATH in your .bash_profile (or .zshenv if you use zsh) as other users have suggested.
Download Android Platform Tools for macOS from:
https://developer.android.com/studio/releases/platform-tools
Extract to your somewhere e.g ~/installs/platform-tools
Add that folder to path by running:
echo 'export PATH=$PATH:~/installs/platform-tools' >> ~/.zshrc
Either restart terminal or run:
source ~/.zshrc
Assuming that you are using zsh.
This totally worked for me, after dickering around for a while after installing Android Studio:
Make sure you have the .bash_profile file. This should be in your [username] directory.
From whatever directory you are on, type this:
echo "export PATH=\$PATH:/Users/${USER}/Library/Android/sdk/platform-tools/" >> ~/.bash_profile
Now, usually you will have this exact path, but if not, then use whatever path you have the platform-tools folder
From the directory where your .bash_profile resides, type this:
. .bash_profile
Now type adb devices. You should see a "List of devices attached" response. Now you do not have to go to the platform-tools directory each and every time to type in the more cryptic command like, ./adb devices!!!
In my case, I installed Android studio, and have some apps (rust lang) that changes the ~/.profile, and adding adb to ~/.bash_profile made the rust un-executable, so I made the changes to the ~/.profile only, as:
$ echo 'PATH=$PATH:$HOME/Library/Android/sdk/platform-tools/' >> ~/.profile
$ source ~/.profile
$ adb --version
Android Debug Bridge version 1.0.41
Version 29.0.4-5871666
Installed as /Users/hasan/Library/Android/sdk/platform-tools/adb
In my case : I did the following (on a mac) :
backed up the ".bash_profile" and ".profile"
cleared all the android related paths.
created the new paths but this time around, I dragged the respective folders : { /.../sdk, /.../tools, /.../platform-tools } into the terminal. I did this for both ".bash_profile" and ".profile".
Then after successfully saving the files each. I restarted the terminal just to be sure about the modifications I made.
I then went on to test if adb was responding now ...
by typing : (in terminal) adb devices
I still had no luck (my devices) where not showing, then I restarted the adb, still.
I went on to do "android update adb" . This just killed and restarted the adb
I tried again still the devices wasnt showing.
I totally backed up my android device and resetted the whole phone back to factory default, went over to activate the device for development and allow for usb debugging in its settings > applications.
******** WORKED LIKE A CHARM ********
I tried again with the command "adb devices" and everything was back to normal the device was visible.
All the best. Just dont give up. It took me a lot of troubleshooting. All the best of luck.
Considering you have already downloaded SDK platform tools.
This command will set ADB locally. So if you close the terminal and open it again, ADB commands won't work until you run this command again.
export PATH=~/Library/Android/sdk/platform-tools:$PATH
These commands will set ADB globally. So once you run these commands no need to set them again next time.
echo 'export PATH=$PATH:~/Library/Android/sdk/platform-tools/' >> ~/.bash_profile
source ~/.bash_profile
If you are using zsh terminal do the following:
1) Open .zprofile file with the editor of your choice like "open -a xcode ~/.zprofile"
2) Add new PATH or Env Variable in .zprofile Save the file and quit the editor.
3) Execute your .zprofile to update your PATH: source ~/.zprofile
Add environment variable for Android Home Targetting Platform Tools
echo 'export ANDROID_HOME=/Users/$USER/Library/Android/sdk' >> ~/.bash_profile
echo 'export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools' >> ~/.bash_profile
Restart Bash
source ~/.bash_profile
Now Check adb
Simply type
adb
on terminal
After trying all the solutions, none of them where working for me.
In my case I had the Android Studio and the adb was correctly working but the Android Studio was not capable to detect the adb. These was because I installed it with homebrew in another directory, not the /Users/$USER/Library/Android/sdk but Usr/Library blabla
Apparently AS needed to have it in his route /Users/$USER/Library/Android/sdk (same place as in preferences SDK installation route)
So I deleted all the adb from my computer (I installed several) and executed these terminal commands:
echo 'export ANDROID_HOME=/Users/$USER/Library/Android/sdk' >> ~/.bash_profile
echo 'export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools' >> ~/.bash_profile
source ~/.bash_profile
adb devices
Well, after that, still wasn't working, because for some reason the route for the adb was /Users/$USER/Library/Android/sdk/platform-tools/platform-tools (yes, repeated) so I just copied the last platform-tools into the first directory with all the license files and started working.
Weird but true
I am using Git Bash on Windows 8. Whenever I type
$ adb devices
I get
bash: adb: command not found
I have already added the path to the PATH variable.
if you haven't solved the problem yet, try adding an alias to your adb.exe
place yourself in the git $home folder
cd $home
if you haven't created the .bashrc file yet
Execute
touch .bahsrc
thereupon
vi .bashrc
add the following line to the file
alias adb='/c/adb/platform-tools/adb.exe'
*note: this path is relative, it depends on where you unzipped the .zip from adb
and save the changes made in vi with ESC then :wq!
GitBash is a Terminal-Emulation software using CYGWIN. The ADB command is a Windows binary that is availabe in a Windows Command Prompt via PATH-variable.
Check this question: Git Bash doesn't see my PATH
It's works my windows machine.
Run the following command on your windows bash profile terminal
echo export "PATH=~/AppData/Local/Android/Sdk/platform-tools:$PATH" >> ~/.bash_profile
Restart your Terminal session
source ~/.bash_profile
Go to My Computer-> Right click -> properties
C:\Users\PCNAME\AppData\Local\Android\Sdk\build-tools
I spent quite sometime figuring how to set up adb on Mac, so I figure writing how to set it up might be useful to some people. adb is the command line tool to install and run android apps on your phone/emulator
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-tools
Add platform-tools to your path
echo '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 path
echo 'export ANDROID_HOME=/Users/$USER/Library/Android/sdk' >> ~/.bash_profile
echo 'export PATH="$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools"' >> ~/.bash_profile
Refresh 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/tools
Run the SDK Manager
sh ~/.android-sdk-macosx/tools/android
Uncheck everything but Android SDK Platform-tools (optional)
Click Install Packages, accept licenses, click Install. Close the SDK Manager window.
Add platform-tools to your path
echo '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
echo "export PATH=\$PATH:/Users/${USER}/Library/Android/sdk/platform-tools/" >> ~/.bash_profile && source ~/.bash_profile
If you put the android-sdks folder in other directory, replace the path with the directory android-sdks/platform-tools is in
Only for zsh users in iterm2 in macOS
type the following two commands to add the android sdk and platform-tools to your zsh in iterm2 in macOS
echo 'export ANDROID_HOME=/Users/$USER/Library/Android/sdk' >> ~/.zshrc
echo 'export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools' >> ~/.zshrc
After adding the two command to ~/.zshrc you need to source the zsh.
source ~/.zshrc
This Works Flawless....
In terminal Run both commands next to each other
export ANDROID_HOME=/Users/$USER/Library/Android/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
NOTE: Path for adb has changed since Android Studio 1.0.xx
For bash shell, use:
echo 'export PATH=$PATH:'$HOME'/Library/Android/sdk/platform-tools' >> ~/.bash_profile
For tcsh shell, use:
echo 'setenv PATH $PATH\:'$HOME'/Library/Android/sdk/platform-tools' >> ~/.tcshrc
2022 Solution
If you have Android Studio installed already and Terminal isn't picking up ADB, here's a one-liner that should fix it:
sudo ln -s ~/Library/Android/sdk/platform-tools/adb /usr/local/bin
If you are using zsh shell and after trying all this solutions, you still need to set $PATH and $ANDROID_HOME every time you open new terminal instance, then here is your answer:
step 1: in terminal run nano ~/.zshrc
step 2: paste following command at the end of the file
export ANDROID_HOME=~/Library/Android/sdk
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH
step 3: After copying the lines above, to save hit control + X. and to confirm hit Y. It will ask you if you wish to change the file name but don't change the name so directly hit enter
step 4: Restart your terminal and execute the adb command.
Bingo!
Here is a step wise information :
Step-1
Start up Terminal and go to your home folder.
cd ~/
Step-2
Open and edit .bash_profile file
$ open -e .bash_profile
If you don’t have .bash_profile file in your computer path, then create one. Enter below command to create a new file. Once created follow Step-2.
touch .bash_profile
Step-3
Save the below line)
export PATH=${PATH}:/Applications/adt-bundle-mac-x86_64-20140321/sdk/tools
export PATH=${PATH}:/Applications/adt-bundle-mac-x86_64-20140321/sdk/platform-tools
Step-4
Refresh the file using below command
$ source .bash_profile
$ echo $PATH
You should see your android path set in the output now.
Personally I just source my .bashrc in my .bash_profile:
echo 'source ~/.bashrc' >> ~/.bash_profile
So I put it in my .bashrc. And I'm using Android Studio, so it was a different path.
echo 'PATH=$PATH:$HOME/Library/Android/sdk/platform-tools/' >> ~/.bashrc
You may also want the following:
echo 'ANDROID_HOME=$HOME/Library/Android/sdk' >> ~/.bashrc
The simplest way to use adb command on your Mac systems would be to add the path to the platform-tools (where adb lives) into your bash_profile.
Steps to add the adb path:
1. open the bash_profile: This can be done by using the following commands
open ~/.bash_profile
This opens up the bash_profile in an editor.
Locate the platform_tools, usually they are present at the following location: Users/"user_folder"/Library/Android/sdk/platform_tools
Paste the following command in the bash_profile file which opens up:
export PATH=$PATH:/Users/A374375/Library/Android/sdk/platform-tools
Save the file using the command:
source ~/.bash_profile
Check if the path is saved by typing: echo $PATH : You should be able to find the entire path displayed in the output.
Type adb to see if the configuration worked. If you have any devices connected to the machine or any emulators running on your system they would be displayed when you type adb devices
output for adb devices
For Mac users :
Step 1: Install the Android Studio
Step2 : Open the terminal and type
cd
Step 3: Type below mentioned command changing the userName:
export PATH=“/Users/{user_name}/Library/Android/sdk/platform-tools”:$PATH
cd sdk/platform-tools/ and then use ./adb devices instead
On MacOS Big Sur do the following:
Open config file:
nano ~/.zshrc
Add paths to PATH variable:
export PATH=~/Library/Android/sdk/tools:$PATH
export PATH=~/Library/Android/sdk/platform-tools:$PATH
close file and save changes.
Then in terminal write:
source ~/.zshrc
And then you'll be able to run:
adb devices
adb kill-server
If you using zsh then you need do the add the following to your .zshrc
Steps:
Step 1: Open your .zshrc profile
open -e .zshrc
Step 2: Add the following to the file
export PATH=$PATH:/Users/${YourUser}/Library/Android/sdk/platform-tools
export ANDROID_HOME=/Users/${YourUser}/Library/Android/sdk
Step 3: Save the file and close.
Step 4: Reload the .zshrc
source .zshrc
Step 5: Check the devices connected
adb devices
MAC Solution.
cd /Users/<user>/Library/Android/sdk/platform-tools
./adb devices
if you are using Android Studio in MAC OS X , you could exec the following command in your terminal app:
echo 'alias adb="/Applications/Android\ Studio.app/sdk/platform-tools/adb"' >> .bashrc
exec $SHELL
and next:
adb devices
and you should be showing a list with your android devices connected via USB cable in your MAC, for example something like this:
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
deb7bed5 device
For macOS Users Updated to MacOs Catalina,
~/.bash_profile changed to ~/.zshrc
So ,to run adb command and all other commands already exported to ~/.bash_profile easy walkaround is to export bash_profile to zshrc
To do that,
1) Navigate to the home directory in finder
2) I used Cmd + Shift + . to show the hidden files in Finder
3) Create .zshrc file if already not exist
4) Add line "source ~/.bash_profile" without quotes
5) Save
6) Quit and open terminal
start using adb devices
Here's a detailed manual:
http://codexpi.com/add-android-adb-path-mac-os-x-mavericks/
To sum this up:
Create and open the bash_profile file
touch .bash_profile
open -e .bash_profile
Add the path of the platform-tools folder (within the Android SDK)
export PATH="$PATH:/Users/USERNAME/PATH TO ANDROID SDK/platform-tools/
Run the command . .bash_profile to update (no need to restart the terminal)
If you are using ZSH and have Android Studio 1.3:
1. Open .zshrc file (Located in your home directory, file is hidden so make sure you can see hidden files)
2. Add this line at the end: alias adb="/Users/kamil/Library/Android/sdk/platform-tools/adb"
3. Quit terminal
4. Open terminal and type in adb devices
5. If it worked it will give you list of all connected devices
Mac OS
Open Terminal
touch ~/.bash_profile; open ~/.bash_profile
Copy and paste:
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
command + S for save.
If you are setting the path in Catalina use below command one after another in the terminal. It's working fine for me.
export ANDROID_HOME=/Users/$USER/Library/Android/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
source ~/.bash_profile
Commenting with some updated information from 2018.
Executable Binaries for Platform tools are made available for mac by Android here: https://developer.android.com/studio/releases/platform-tools.html
Download these to your mac. Place them in a directory e.g. I placed in ~/Software/platform-tools
If you have root access, the easiest way I have found on a mac is to add your directories to the list in /etc/paths. I like this way because after a few additions the $PATH starts to look too messy and hard to read, the /etc/pathshas everything in separate line, clean and organized. The downside is that you require root access.
$ cat /etc/paths # check contents of the file
$ sudo nano /etc/paths
Paste the full path of your platform-tools directory (something like /Users/GodZilla/Software/platform-tools/adb) at the end of this list and save. Quit and Open terminal again and check if it sees your platform-tools directory.
$ which adb
/Users/GodZilla/Software/platform-tools/adb
$ which fastboot
/Users/GodZilla/Software/platform-tools/fastboot
If you don't have root access, just add the platform-tools directory to $PATH in your .bash_profile (or .zshenv if you use zsh) as other users have suggested.
Download Android Platform Tools for macOS from:
https://developer.android.com/studio/releases/platform-tools
Extract to your somewhere e.g ~/installs/platform-tools
Add that folder to path by running:
echo 'export PATH=$PATH:~/installs/platform-tools' >> ~/.zshrc
Either restart terminal or run:
source ~/.zshrc
Assuming that you are using zsh.
This totally worked for me, after dickering around for a while after installing Android Studio:
Make sure you have the .bash_profile file. This should be in your [username] directory.
From whatever directory you are on, type this:
echo "export PATH=\$PATH:/Users/${USER}/Library/Android/sdk/platform-tools/" >> ~/.bash_profile
Now, usually you will have this exact path, but if not, then use whatever path you have the platform-tools folder
From the directory where your .bash_profile resides, type this:
. .bash_profile
Now type adb devices. You should see a "List of devices attached" response. Now you do not have to go to the platform-tools directory each and every time to type in the more cryptic command like, ./adb devices!!!
In my case, I installed Android studio, and have some apps (rust lang) that changes the ~/.profile, and adding adb to ~/.bash_profile made the rust un-executable, so I made the changes to the ~/.profile only, as:
$ echo 'PATH=$PATH:$HOME/Library/Android/sdk/platform-tools/' >> ~/.profile
$ source ~/.profile
$ adb --version
Android Debug Bridge version 1.0.41
Version 29.0.4-5871666
Installed as /Users/hasan/Library/Android/sdk/platform-tools/adb
In my case : I did the following (on a mac) :
backed up the ".bash_profile" and ".profile"
cleared all the android related paths.
created the new paths but this time around, I dragged the respective folders : { /.../sdk, /.../tools, /.../platform-tools } into the terminal. I did this for both ".bash_profile" and ".profile".
Then after successfully saving the files each. I restarted the terminal just to be sure about the modifications I made.
I then went on to test if adb was responding now ...
by typing : (in terminal) adb devices
I still had no luck (my devices) where not showing, then I restarted the adb, still.
I went on to do "android update adb" . This just killed and restarted the adb
I tried again still the devices wasnt showing.
I totally backed up my android device and resetted the whole phone back to factory default, went over to activate the device for development and allow for usb debugging in its settings > applications.
******** WORKED LIKE A CHARM ********
I tried again with the command "adb devices" and everything was back to normal the device was visible.
All the best. Just dont give up. It took me a lot of troubleshooting. All the best of luck.
Considering you have already downloaded SDK platform tools.
This command will set ADB locally. So if you close the terminal and open it again, ADB commands won't work until you run this command again.
export PATH=~/Library/Android/sdk/platform-tools:$PATH
These commands will set ADB globally. So once you run these commands no need to set them again next time.
echo 'export PATH=$PATH:~/Library/Android/sdk/platform-tools/' >> ~/.bash_profile
source ~/.bash_profile
If you are using zsh terminal do the following:
1) Open .zprofile file with the editor of your choice like "open -a xcode ~/.zprofile"
2) Add new PATH or Env Variable in .zprofile Save the file and quit the editor.
3) Execute your .zprofile to update your PATH: source ~/.zprofile
Add environment variable for Android Home Targetting Platform Tools
echo 'export ANDROID_HOME=/Users/$USER/Library/Android/sdk' >> ~/.bash_profile
echo 'export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools' >> ~/.bash_profile
Restart Bash
source ~/.bash_profile
Now Check adb
Simply type
adb
on terminal
After trying all the solutions, none of them where working for me.
In my case I had the Android Studio and the adb was correctly working but the Android Studio was not capable to detect the adb. These was because I installed it with homebrew in another directory, not the /Users/$USER/Library/Android/sdk but Usr/Library blabla
Apparently AS needed to have it in his route /Users/$USER/Library/Android/sdk (same place as in preferences SDK installation route)
So I deleted all the adb from my computer (I installed several) and executed these terminal commands:
echo 'export ANDROID_HOME=/Users/$USER/Library/Android/sdk' >> ~/.bash_profile
echo 'export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools' >> ~/.bash_profile
source ~/.bash_profile
adb devices
Well, after that, still wasn't working, because for some reason the route for the adb was /Users/$USER/Library/Android/sdk/platform-tools/platform-tools (yes, repeated) so I just copied the last platform-tools into the first directory with all the license files and started working.
Weird but true
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:
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.
For zsh users. Add alias adb='/Users/$USER/Library/Android/sdk/platform-tools/adb' to .zshrc file.
Then run source ~/.zshrc command
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
In addition to slhck, this is what worked for me (mac).
To check where your sdk is located.
Open Android studio and go to:
File -> Project Structure -> Sdk location
Copy the path.
Create the hidden .bash_profile in your home.
(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
Then simply use this in your terminal: . ~/.bash_profile
SO post on how to find adb devices
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
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
This 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
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
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
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
Simply install adb with brew
brew cask install android-platform-tools
Check if adb is installed
adb devices
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
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
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.
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
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.
For Mac, Android Studio 3.6.1, I added this to .bash_profile
export PATH="~/Library/Android/sdk/platform-tools/platform-tools":$PATH
Or the alternative solution could be
Make sure you already install for android SDK. Usually it is located under
/Users/your-user-name/Library/Android/sdk
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
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.
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.!
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
It's working fine..
brew install android-sdk
Later on:
android update sdk --no-ui --filter 'platform-tools'
I am trying to develop for android and I want to add the adb to my PATH so that I can launch it really easily. I have added directories before by for some reason adb does not want to be found. This is very frustrating. Has anyone else had this problem before?
I created a file .profile and added the following to it.
export PATH = ${PATH}:/Users/simon/Libs/android-sdk-mac_x86/platform-tools/
export PATH = ${PATH}:/Users/simon/Libs/android-sdk-mac_x86/tools
When I check my environment path I see the following:
/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
So I know that it is added to my PATH variable. Now when I try to run adb I get that it is not found.
-bash: ./adb: No such file or directory
This is very very frustrating. Could it be a problem with permissions? Has anyone had this problem with OSX and Android?
Add to PATH for every login
Total control version:
in your terminal, navigate to home directory
cd
create file .bash_profile
touch .bash_profile
open file with TextEdit
open -e .bash_profile
insert line into TextEdit
export
PATH=$PATH:/Users/username/Library/Android/sdk/platform-tools/
save file and reload file
source ~/.bash_profile
check if adb was set into path
adb version
One liner version
Echo your export command and redirect the output to be appended to .bash_profile file and restart terminal. (have not verified this but should work)
echo "export PATH=$PATH:/Users/username/Library/Android/sdk/platform-tools/
sdk/platform-tools/" >> ~/.bash_profile
Alternative: Install adb the easy way
If you don't want to have to worry about your path or updating adb manually, you can use homebrew instead.
brew cask install android-platform-tools
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.
On my Macbook Pro, I've added the export lines to ~/.bash_profile, not .profile.
e.g.
export PATH=/Users/me/android-sdk-mac_86/platform-tools:/Users/me/android-sdk-mac_86/tools:$PATH
Just encase anyone finds this SO post when using Android Studio which includes the SDK has part of the App package (on Mac OSX).
So as #davecaunt and #user1281750 noted but insert the following line to .bash_profile
export PATH=/Applications/Android\ Studio.app/sdk/tools:/Applications/Android\ Studio.app/sdk/platform-tools:$PATH
The answer for MAC should be:
Open your bash_profile with the following commands: open ~/.bash_profile
In case base profile file doesn't exist, create a new one with the following command: touch .bash_profile then repeat phase 1.
Add the following line: export PATH=/Users/"YOURUSER"/Library/Android/sdk/platform-tools:$PATH
Restart your bash window and test by typing adb shell
Good luck! :-)
In your terminal, navigate to home directory
cd
create file .bash_profile
touch .bash_profile
open file with TextEdit
open -e .bash_profile
insert line into TextEdit
export PATH=$PATH:/Users/username/Library/Android/sdk/platform-tools/
save file and reload file
source ~/.bash_profile is very important
check if adb was set into path
adb version
It should be fine now.
I use zsh and Android Studio. I use a variable for my Android SDK path and configure in the file ~/.zshrc:
export ANDROID_HOME=/Applications/Android\ Studio.app/sdk
export PATH="$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools:$PATH"
Note: Make sure not to include single or double quotes around the specified path. If you do, it won't work.
Android Studio v1.2 installs the adb tool in this path:
~/Library/Android/sdk/platform-tools/adb
So it goes like this:
Run Terminal
run adb version and expect an error output
touch ~/.bash_profile
open ~/.bash_profile
add the above path before the 'closing' :$PATH
source ~/.bash_profile
run adb version and expect an output
Good luck!
It appears that you're still trying to execute adb with ./adb. That asks the shell to run the program named adb in the current working directory.
Try just adb without ./.
In order to make the terminal always have the file ~/.bashrc and there put the path you wish to use, by adding:
export PATH=$PATH:/XXX
where XXX is the path that you wish to use.
for adb, here's what i use:
export PATH=$PATH:/home/user/Android/android-sdk-linux_x86/platform-tools/
(where "user" is my user name).
2nd solution is explained below. But when i close the terminal the change which i made in path variable gets lost. Thus i prefer the first way!
If you are Catalina user follow this
Make sure to be in the Home directory
cd ~
To persist PATH changes and prevent it to be cleaned up after closing the Terminal app, you need to keep the variables in the zshrc file for Catalina
touch .zshrc
Open it with the TextEditor
open -e .zshrc
Insert the command below to add ADB as PATH variable (replace username with your own)
export PATH=$PATH:/Users/username/Library/Android/sdk/platform-tools/
Save the file and close the TextEditor app. Back to the Terminal app, insert the following to source the file
source .zshrc
And you’re done! Let’s test if it was successful
adb version
You should expect something like
Android Debug Bridge version 1.0.41
Version 31.0.2-7242960
Installed as /Users/username/Library/Android/sdk/platform-tools//adb
I added export PATH=${PATH}:/Users/mishrapranjal/android-sdks/platform-tools/ into both places .bash_profile and .profile to make sure it works. Still it wasn't working and then I looked at sarnold's tip about restarting terminal and it worked like a charm.
It saved my time of adding every time this into the PATH whenever I had to run adb.
Thank you guys.
If anyone can't seem to get there .bash_profile file to take any new Paths AND you have other commands in that file (like alias commands) then try moving the PATH statements to the top of the file.
That is the only thing that worked for me. The reason it worked was because I had some typos in my alias commands and apparently this file throws an error and exits if it runs into a problem. So that is why my PATH statements weren't being run. Moving it to the top just let it run first.
In bash profile
just add -
export PATH=$PATH:/Users/username/Library/Android/sdk/platform-tools/
and then in terminal run -
adb version
All answers are well written and helpful but there is one thing that I want to mention. Before adding path variable to .bash_profile kindly check your default shell.
Because i was seting path variable in .bash_profile file but my default shell was zsh that's why i have to run source ~/.bash_profile each time before using adb command.
So first check your default shell:
echo $SHELL
if the output is /bin/bash then you should set path variable in
.bash_profile
If the output is /bin/zsh then you should set path variable in .zshrc
And here is my path variable:
export ANDROID_SDK_ROOT="/Users/aliasjad/Library/Android/sdk"
export PATH="$ANDROID_SDK_ROOT/platform-tools:$PATH"