[android] adb command not found

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?

This question is related to android macos terminal adb

The answer is


Make sure adb is in your user's $PATH variable.

or

You can try to locate it with whereis and run it with ./adb


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


In my case with Android Studio 1.1.0 path was this

/Users/wzbozon/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

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:

  1. Go to the directory where you placed the SDK:

    cd /Users/mansour/Library/Developer/Android/sdk/platform-tools

  2. Type the adb command with ./ to use it from the current directory.

    ./adb tcpip 5555

    ./adb devices

    ./adb connect 192.168.XXX.XXX


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  

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

This is the easiest way and will provide automatic updates.

  1. install homebrew

    ruby -e "$(curl -fsSL 
    https://raw.githubusercontent.com/Homebrew/install/master/install)"
    
  2. Install adb

    brew cask install android-platform-tools
    
  3. Start using adb

    adb devices
    

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


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.


you have to move the adb command to /bin/ folder

in my case:

sudo su
mv /root/Android/Sdk/platform-tools/adb /bin/

I solved this issue by install adb package. I'm using Ubuntu.

sudo apt install adb

I think this will help to you.


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.


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

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.


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.


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:

  1. Launch Android Studio
  2. Launch SDK Manager via Tools -> Android -> SDK Manager
  3. 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


In my case this is the solving of this problem

  1. Make sure you have installed the android SDK. Usually the location of SDK is located to this location

    /Users/your-user/Library/Android/sdk

  2. After that cd to that directory.

  3. Once you are in that directory type this command ./platform-tools/adb install your-location-of apk


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


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 

+ 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")


For mac users with zshrc file (who don't have bash profile).

  1. Go to your user folder and tap cmd + fn + shift + "." (on Mac laptop keyboard !)

  2. Hidden files are visible, open .zhrc file with a Text Editor

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

  1. Open terminal and reload the file with this :
source ~/.zshrc

Now you can use adb command lines !


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

Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to macos

Problems with installation of Google App Engine SDK for php in OS X dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib error running php after installing node with brew on Mac Could not install packages due to an EnvironmentError: [Errno 13] How do I install Java on Mac OSX allowing version switching? Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) Can't compile C program on a Mac after upgrade to Mojave You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory. (mac user) How can I install a previous version of Python 3 in macOS using homebrew? Could not install packages due to a "Environment error :[error 13]: permission denied : 'usr/local/bin/f2py'"

Examples related to terminal

Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) Can't compile C program on a Mac after upgrade to Mojave Flutter command not found VSCode Change Default Terminal How to switch Python versions in Terminal? How to open the terminal in Atom? Color theme for VS Code integrated terminal How to edit a text file in my terminal How to open google chrome from terminal? Switch between python 2.7 and python 3.5 on Mac OS X

Examples related to adb

ADB server version (36) doesn't match this client (39) {Not using Genymotion} ADB device list is empty "unable to locate adb" using Android Studio Run react-native on android emulator Solving "adb server version doesn't match this client" error Adb install failure: INSTALL_CANCELED_BY_USER Session 'app': Error Installing APK Where is adb.exe in windows 10 located? How to debug in Android Studio using adb over WiFi Set adb vendor keys