Android PATH set up in the Mac OS - android

I use Mac OS and installed the Android SDK using the following command from the terminal,
brew tap caskroom/cask
brew cask install android-sdk
Then I updated the .bash_profile like
export ANDROID_HOME=/Users/Somename/Library/Android/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Is the path is set up correctly and how can I test that?

That looks correct. You need to refresh your terminal with the contents of .bash_profile by either opening a new terminal window, or by typing
. ~/.bash_profile
Note the initial .. You can then check your path is correct by typing
echo $PATH
If all is correct, then you should be able to run binary tools within the Android SDK without specifying the full path, e.g.
adb devices
For reference, this is my own .bashrc file on my Debian machine:
export ANDROID_HOME=$HOME/Development/Android/sdk
export ANDROID_NDK_HOME=$HOME/Development/Android/android-ndk-r12b
export PATH=$PATH:$HOME/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools:$ANDROID_NDK_HOME

Related

Unable to set PATH in WebStorm for Android SDK in Apache Cordova in MAC OS

I am new to Apache Cordova and making Hybrid Applications.
I have tried all the options but I am still not able to give my Android SDK Path in WebStorm (the IDE that I am using). I am using Mac Machine running on OS Mojave.
sudo export ANDROID_HOME="/Users/nabiharaza/Library/Android/sdk"
sudo export PATH="$HOME/Android/tools:$/Users/nabiharaza/Library/Android/sdk"
sudo export PATH="$HOME/Android/platform-tools:$/Users/nabiharaza/Library/Android/sdk"
I have already run these commands on the terminal.
The path where my SDK is "/Users/nabiharaza/Library/Android/sdk"
Can someone help me with fixing this issue.
when you run sudo export, you won't change anything to the shell of the current user. you have to edit ~/.bashrc (or however the current user's profile would be called on OSX; just see ls -la $HOME) and add this:
export ANDROID_HOME="/Users/nabiharaza/Library/Android/sdk"
export PATH=$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools/bin:$PATH

How to set ANDROID_HOME path in ubuntu?

How to set ANDROID_HOME path in ubuntu?
Please provide the steps.
In the console just type these :
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
If you want to make it permanent just add those lines in the ~/.bashrc file
I would like to share an answer that also demonstrates approach using the Android SDK provided by the Ubuntu repository:
Install Android SDK
sudo apt-get install android-sdk
Export environmental variables
export ANDROID_HOME="/usr/lib/android-sdk/"
export PATH="${PATH}:${ANDROID_HOME}tools/:${ANDROID_HOME}platform-tools/"
Assuming you have the sdk extracted at ~/Android/Sdk,
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
Add the above lines to the file ~/.bashrc (located at home/username/.bashrc) to make it permanent for the current user. Run source ~/.bashrc to apply the changes or restart your terminal.
(or)
Run the above lines on a terminal window to make it available for the session.
To test if you have set it up correctly,
Run the below commands on a terminal window
echo $ANDROID_HOME
user#host:~$ echo $ANDROID_HOME
/home/<user>/Android/Sdk
which android
user#host:~$ which android
/home/<user>/Android/Sdk/tools/android
Run android on a terminal window, If it opens up Android SDK Manager, you are good to go.
better way is to reuse ANDROID_HOME variable in path variable. if your ANDROID_HOME variable changes you just have to make change at one place.
export ANDROID_HOME=/home/arshid/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Initially go to your home and press Ctrl + H it will show you hidden files now look for .bashrc file, open it with any text editor then place below lines at the end of file.
export ANDROID_HOME=/home/varun/Android/Sdk
export PATH=$PATH:/home/varun/Android/Sdk/tools
export PATH=$PATH:/home/varun/Android/Sdk/platform-tools
Please change /home/varun/Android/Sdk path to your SDK path.
Do the same for tools and platform-tools.
After this save .bashrc file and close it.
Now you are ready to use ADB commands on terminal.
Add the following to your ~/.bashrc file. Log-out and log-in. I have my sdk in $HOME/Documents/Android/sdk you have to replace it with where you keep your sdk folder
# Android Path
PATH=$PATH:$HOME/Documents/Android/sdk:$HOME/Documents/Android/sdk/tools
export PATH
# For SDK version r_08 and higher, also add this for adb:
PATH=$PATH:$HOME/Documents/Android/sdk/platform-tools
export PATH
first open the .bashrc file by gedit ~/.bashrc
# Added ANDROID_HOME variable.
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
save the file and reopen the terminal
echo $ANDROID_HOME
it will show the path like /home/pathTo/Android/Sdk
Applies to Ubuntu and Linux Mint
In the archive:
sudo nano .bashrc
Add to the end:
export ANDROID_HOME=${HOME}/Android/Sdk
export PATH=${PATH}:${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/tools
Restart the terminal and doing: echo $ HOME or $ PATH, you can know these variables.
Download the Android SDK to the machine. (Suppose that the location is /home/zelong/Android/Sdk) (home/username/Android/Sdk)
Add these lines to the file ~/.bashrc (located at home/username/.bashrc)
export ANDROID_HOME="/home/zelong/Android/Sdk"
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
This will make it permanent for the current user because every time the machine boots, it will run this script and set the enviroment path.
After making this change, remember to save it.
Then run source ~/.bashrc to apply the changes or restart your terminal.
Test if it works:
zelong#zelong-ThinkPad-T430:~$ echo $ANDROID_HOME
/home/zelong/Android/Sdk
zelong#zelong-ThinkPad-T430:~$ which android
/home/zelong/Android/Sdk/tools/android
zelong#zelong-ThinkPad-T430:~$ which adb
/home/zelong/Android/Sdk/platform-tools/adb
As we can see,
android command line locates under tools
adb command line locates under platform-tools
This is what work for me,
Assuming you have the sdk extracted at ~/Android/Sdk,
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
Add the above lines to the file ~/.bashrc (located at home/username/.bashrc) to make it permanent for the current user. Run source ~/.bashrc to apply the changes or restart your terminal.
(or)
Run the above lines on a terminal window to make it available for the session.
To test if you have set it up correctly,
Run the below commands on a terminal window
echo $ANDROID_HOME
user#host:~$ echo $ANDROID_HOME
You will get
/home/<user>/Android/Sdk
You can run this too
which android
user#host:~$ which android
/home/<user>/Android/Sdk/tools/android
Run android on a terminal, If it opens up Android SDK Manager, you are good to go.
you can edit the environment variable file in Ubuntu to set android home globally.
[1] run this command in terminal
sudo -H gedit /etc/environment
[2] your envirmnent file content will look like the below one
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
[3] in environment file add android sdk path as follows:-
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
ANDROID_HOME="/home/yourPathTo/Android/Sdk"
[4] then you can check the Android home path in the terminal with the following command:-
echo $ANDROID_HOME
If path is still not set then restart the system to get the applied changes.
In my case it works with a little change. Simply by putting :$PATH at the end.
# andorid paths
export ANDROID_HOME=$HOME/Android/Sdk
export PATH="$ANDROID_HOME/tools:$PATH"
export PATH="$ANDROID_HOME/platform-tools:$PATH"
export PATH="$ANDROID_HOME/emulator:$PATH"
In the terminal just type these 3 commands to set the ANDROID_HOME Variable :
$ export ANDROID_HOME=~/Android/Sdk
/Android/Sdk is the location of Sdk, this might get change in your case
$ PATH=$PATH:$ANDROID_HOME/tools
$ PATH=$PATH:$ANDROID_HOME/platform-tools `
Note : This will set the path temporarily so what ever action
you have to perform, perform on the same terminal.
If you run android with sudo it will install sdk in /root/Android/Sdk
so check if that is the case.
And if you are using dont run cordova with sudo it will look sdk in root also may be.
Above code for setting path is works fine.
I was facing the same problem with linux ANDROID_HOME path
Note:
1- Add parameters
2- Make or Rebuild project
3- Restart your PC
How to add parameters using terminal:
Open your terminal write
gedit .bashrc
another window will be open and then add the following lines at the end of the windows.
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
then back to terminal and type
source .bashrc
to save your changes in bashrc file at the end restart your computer.
add to file
~/.profile
export ANDROID_HOME=/opt/android-sdk
Path to the SDK
Then reset the computer
Had the same issue,
in the terminal you can type:
export ANDROID_HOME=$HOME/Android/Sdk
or any other location depending on where you installed the sdk.
export PATH=$PATH:$ANDROID_HOME/platform-tools
Hope it helps!
sudo su -
gedit ~/.bashrc
export PATH=${PATH}:/your path
export PATH=${PATH}:/your path
export PATH=${PATH}:/opt/workspace/android/android-sdk-linux/tools
export PATH=${PATH}:/opt/workspace/android/android-sdk-linux/platform-tools
You can append this line at the end of .bashrc file-
export PATH=$PATH:"/opt/Android/Sdk/platform-tools/"
here /opt/Android/Sdk/platform-tools/ is installation directory of Sdk.
.bashrc file is located in home folder
vi ~/.bashrc
or if you have sublime installed
subl ~/.bashrc
open ~/.bashrc file and paste at the end
export PATH=$PATH{}:/path-from-home-dir/android/sdk/tools
export PATH=$PATH{}:/path-from-home-dir/android/sdk/platform-tools

Android command not found even PATH set

hi i am using ubuntu 12.04. and in ~/.bashrc file I set following things
export ANDROID_HOME=/home/nilkash/Downloads/android-sdk-linux/platform-tools
But still it gives me android: command not found error. how to set path for android. Need Help. Thank you.
To include the SDK's tools and platform-tools directories in your PATH environment open text editor to create or modify the ~/.bash_profile file, adding below line:
export PATH=${PATH}:/home/nilkash/Downloads/android-sdk-linux/platform-tools:/home/nilkash/Downloads/android-sdk-linux/tools
For Ubuntu:
To modify the PATH variable of your system, you need to edit your .bashrc file. To do so, in a terminal, execute the following command:
$ nano ~/.bashrc
You will now have the Nano text editor enabled on the terminal. Now, at the very top of the file, enter the following:
#AndroidDev PATH
export PATH=${PATH}:~/android-sdk-linux/tools
export PATH=${PATH}:~/android-sdk-linux/platform-tools
Once you're finished, press CTRL + X, Y, and then hit Enter to save your changes and exit the Nano text editor.
To reload the ~/.bashrc without re log in:
. ~/.bashrc or source ~/.bashrc
References:
- help.ubuntu.com/community/AndroidSDK- How do I reload .bashrc without logging out and back in?
1) Check in System Settings -> Details, whether your Ubuntu is 32-bit or 64-bit
2) If your Ubuntu is a 32-bit OS then run this sudo apt-get install libgl1-mesa-dev
In case of 64-bit OS run this sudo apt-get install ia32-libs
3) run this sudo apt-get install openjdk-6-jdk or better this sudo apt-get install openjdk-7-jdk
4) Download SDK platform tools from here http://developer.android.com/sdk/index.html
5) Unzip downloaded file "adt-bundle-linux-x86_64-20131030.zip" (you can have a little bit different name ;). But you should get folder contained two sub folder - sdk and eclipse
6) Run this nautilus ~
7) In opened window create folder 'android-sdk-linux'
8) copy the all entire contents of folder sdk (from unzipped archive) to this new folder 'android-sdk-linux'
9) try run this cd ~/android-sdk-linux/tools then this ./android. If you did all right you should see Android SDK Manager
10) run this sudo gedit ~/.bashrc in opened editor add this in very top
#AndroidDev PATH
export PATH=${PATH}:~/android-sdk-linux/tools
export PATH=${PATH}:~/android-sdk-linux/platform-tools
11) save and close
12) run exec bash then try run android
13) give write permissions to android-sdk-linux folder
Enjoy! ;)
android: command not found error
Solution for Linux and Mac:
1) Export your Android Sdk path to the ANDROID_HOME variable
$ export ANDROID_HOME=~/Android/Sdk (where ~/Android/Sdk is a full path to your Sdk folder)
(change "~" to "$HOME" on Mac)
2) Export Sdk tools to the PATH variable
$ export PATH=$ANDROID_HOME/tools:$PATH
That's it!
I tried
sudo nano /etc/profile
and appended these after the fi
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
export ANDROID_HOME=/home/dev/Android/Sdk
export PATH=$PATH:$JAVA_HOME/bin:$ANDROID_HOME/platform-tools:ANDROID_HOME/tools
export JAVA_HOME
export ANDROID_HOME
and after saving the file
exec bash
these got my android command working, I had set PATH in .bashrc which was not working for me
Hope It'll help somebody
Environment variables can be defined permanently by editing the .profile file in your home directory. Here's how:
Edit your .profile file with a command like gedit ~/.profile. Append this to the end of the file:
export ANDROID_SDK_HOME=/home/nilkash/Downloads/android-sdk-linux/platform-tools
You can source .profile to make it apply right away. Each time you restart your system, the .profile file is loaded, restoring this setting.
OR
This below method works 100% for me on Ubuntu 12.04:
Start the terminal
$gedit .bashrc
Add the below line at the enc of the file:
PATH=$PATH:/home/nilkash/Downloads/android-sdk-linux/platform-tools/
Note: gedit must be performed only on .bashrc and NOT on .bashrc~
Please do accept the answer if it works for you.
if the problem still exist please make sure that you have the right permissions
try
sudo chmod -R 777 /home/your-user-name/.cordova/
Also make sure that you are NOT using sudo to add Android as a platform
This is incorrect in the default Cordova installation
sudo cordova platform add android
Just do
cordova platform add 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?
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

Not able to access adb in OS X through Terminal, "command not found"

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'

Categories

Resources