Trying to add adb to PATH variable OSX

AndroidMacosAdb

Android Problem Overview


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?

Android Solutions


Solution 1 - 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

Solution 2 - Android

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

Solution 3 - Android

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.

Solution 4 - Android

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

Solution 5 - Android

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

Solution 6 - Android

The answer for MAC should be:

  1. Open your bash_profile with the following commands: open ~/.bash_profile

  2. In case base profile file doesn't exist, create a new one with the following command: touch .bash_profile then repeat phase 1.

  3. Add the following line: export PATH=/Users/"YOURUSER"/Library/Android/sdk/platform-tools:$PATH

  4. Restart your bash window and test by typing adb shell

Good luck! :-)

Solution 7 - Android

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.

Solution 8 - Android

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.

Solution 9 - Android

Android Studio v1.2 installs the adb tool in this path:

~/Library/Android/sdk/platform-tools/adb

So it goes like this:

  1. Run Terminal
  2. run adb version and expect an error output
  3. touch ~/.bash_profile
  4. open ~/.bash_profile
  5. add the above path before the 'closing' :$PATH
  6. source ~/.bash_profile
  7. run adb version and expect an output

Good luck!

Solution 10 - Android

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

Solution 11 - Android

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

Solution 12 - Android

enter image description here

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!

enter image description here

Solution 13 - Android

If you are Catalina user follow this

  1. Make sure to be in the Home directory

    cd ~

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

  3. Open it with the TextEditor

    open -e .zshrc

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

  5. Save the file and close the TextEditor app. Back to the Terminal app, insert the following to source the file

    source .zshrc

  6. And you’re done! Let’s test if it was successful

    adb version

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

Solution 14 - Android

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.

Solution 15 - Android

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.

Solution 16 - Android

In bash profile just add -

> export PATH=$PATH:/Users/username/Library/Android/sdk/platform-tools/

and then in terminal run -

> adb version

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionskokoView Question on Stackoverflow
Solution 1 - AndroidTobrunView Answer on Stackoverflow
Solution 2 - AndroidbrismuthView Answer on Stackoverflow
Solution 3 - AndroidLaCView Answer on Stackoverflow
Solution 4 - AndroidDavid Snabel-CauntView Answer on Stackoverflow
Solution 5 - AndroidscottyabView Answer on Stackoverflow
Solution 6 - AndroidAvi LevinView Answer on Stackoverflow
Solution 7 - Androidkotini tirumulaView Answer on Stackoverflow
Solution 8 - AndroidcolabugView Answer on Stackoverflow
Solution 9 - AndroidnurnachmanView Answer on Stackoverflow
Solution 10 - AndroidsarnoldView Answer on Stackoverflow
Solution 11 - Androidandroid developerView Answer on Stackoverflow
Solution 12 - AndroidmetisView Answer on Stackoverflow
Solution 13 - AndroidAristo MichaelView Answer on Stackoverflow
Solution 14 - AndroidPranjalView Answer on Stackoverflow
Solution 15 - AndroidJoshJoeView Answer on Stackoverflow
Solution 16 - AndroidAyushi SharmaView Answer on Stackoverflow