Trying to add adb to PATH variable OSX
Solution 1
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 2
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 3
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 4
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
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
skoko
Updated on September 03, 2021Comments
-
skoko over 2 years
I am trying to develop for android and I want to add the
adb
to myPATH
so that I can launch it really easily. I have added directories before by for some reasonadb
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 runadb
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?
-
skoko about 13 yearsTried that too. Nothing. This is seriously driving me nuts.
-
skoko about 13 yearsTried both ./adb and adb.. Nothing, I have no idea what is wrong with this.
-
skoko about 13 yearsfunny. I opened up that file...This exact line was already in there. I think eclipse added that while installing the plug-in?
-
LaC about 13 yearsWhere is adb supposed to be located? Check that it's there and that it has execute permissions (cd to the directory and do ls -l adb).
-
skoko about 13 yearsIf I go to the directory I can run it no problem. Here is the output. -rwxrwxrwx 1 simon staff 179312 28 Feb 02:48 adb
-
sarnold about 13 years@user569594: did you re-start your shell after editing
.profile
? (i.e., if youecho $PATH
beforeadb
, do you see the new directories?) -
skoko about 13 yearsyes, I mentioned that in the question. It shows up in the echo, bash for some reason just CAN NOT SEE IT.
-
sarnold about 13 years@user569594: sorry, had to ask, I've seen people edit their shell start-up scriptss, test their changes by starting a new shell, and forget to re-start their current shell and wonder where it fails... :)
-
David Snabel-Caunt about 13 yearsIt is possible, though I added mine myself.
-
sarnold about 13 years@LaC, missing execute permissions on the file would be reported with
bash: /bin/ls: Permission denied
-
skoko about 13 yearsThanks for this answer. It turns out both .profile and .bash_profile were both there. I had the values in .profile and yea. Now it works. Thanks a lot guys.
-
David Snabel-Caunt about 13 yearsAccording to johnnywey.wordpress.com/2008/04/17/fixing-bash-profile-in-os-x you may have conflicting profiles
-
sarnold about 13 years@user569594: I don't like that your
adb
executable is world-writable. I wonder if Apple has modifiedbash
to not execute world-writable executables? Trychmod 755 adb
and try again? -
skoko about 13 yearsI think that's exactly what the problem was. Another app (I think MacPorts) created .profile
-
skoko about 13 yearsYea, I made sure to restart. The problem lied in having two profiles in my home directory. A .bash_profile and a .profile
-
skoko about 13 yearsWorks now, I just had two profiles. One over wrote the other. If anyone is doing this use .bash_profile to edit the path variable. I followed a different tutorial that said to use .profile
-
sarnold about 13 years@user569594, cool! If that's the case, @David Caunt's answer looks like the one to
Accept
. :) -
Tobrun over 10 yearsInstead of relauching your terminal you can use the following command to reload the file: ". .bash_profile"
-
Brijesh Thakur about 10 yearsThe penultimate step in the above step is "Restart Terminal" :)
-
Tobrun about 10 yearsRestart terminal should not be necessary, reloading the file should be enough
-
Adam Johns almost 10 yearsDon't forget to restart terminal after you add to PATH.
-
rilar over 9 yearsAwesome! Thx scottyab!
-
Tobrun over 9 yearsUpdate: Probably it doesn't work for you because you are using multiple tabs. Every tab on your terminal has his own session. So reload the .bash_profile in the tab of the "adb version" command.
-
Adam over 9 yearsAlternatively, it's located in Users/[user]/Android/sdk/platform-tools.... I don't like linking to the Applications folder (maybe that's just me though).
-
Mohit over 8 yearscan use export PATH=$PATH:$HOME/Library/Android/sdk/platform-tools/ , just by copy and paste and no need to change the username
-
smets.kevin over 8 yearsMuch, MUCH better then trying to fiddle with PATH, .bash_profile etc.. Thanks!
-
Ryan R over 8 yearsI removed the
sdk/platform-tools/
bit at the end, since this was giving me a bash warning in Android Studio. -
sud007 about 8 yearsI checked like 7 different versions of this tutorial. And I was only able to understand this one and what I am trying to do here! Great, It worked!
-
Adam Mendoza over 7 yearsyup c[_] ~ ᒡ◯ᵔ◯ᒢ
-
The Hungry Androider about 7 yearsFYI, this now gives the error: Error: No available formula with the name "android-platform-tools". Use: brew install Caskroom/cask/android-platform-tools instead
-
brismuth about 7 years@The Hungry Androider - fixed it
-
Kinergy about 6 yearsI haven't tried this but I'm wondering if one installs Android Studio as well as with Homebrew, wondering if this could create a version out of sync problem in the future... just a thought
-
brismuth about 6 yearsIf you have multiple installations, bash will just use one of them consistently (as long as your path is configured the same each time).
-
Justin Noel over 5 yearsYou can also do
source ~/.bash_profile
instead of restarting the terminal. -
xtarsy almost 5 yearsBest and easiest answer!
-
Rahul Rastogi over 4 yearsMy adb command works after using first method, but working till the terminal is opened in the same session. As I close terminal and open new window, then again adb commands doesn't respond.
-
Seyid-Kanan Bagirov almost 4 yearsFirst method work for me, then you need restart your computer
-
Rahul Mishra over 3 yearsThis works now: brew install --cask android-platform-tools