-bash: android: command not found on Mac OSX - android

I've been diving into Android development for a while, and now I want to use some project (helpshift) in my app. On the website they have some example apps in which the readme says: Run the following inside the /HelpshiftDemo folder.
android update project -t android-17 -p .
So I do this, but unfortunately this gives me an error saying -bash: android: command not found. I understand this, because "android" as such doesn't refer to anything on my laptop (Mac OSX). So I thought it is maybe referring to the adb. So I tried replacing android for the direct path to my adb:
/Users/kramer65/dev/adt-bundle-mac-x86_64-20130917/sdk/platform-tools/adb update project -t android-17 -p .
This gives me a humongous output with more information on adb, which is I guess not the expected result.
So my questions; what does android refer to, and how can I fix this on Mac OSX?

The android tool is located in the tools directory in your SDK. You need to add this to your PATH environment variable so that bash can recognize it.
You can do this by adding it to your PATH in your .bash_profile file. This file should be located in your home directory. Create if it doesn't exist using vi .bash_profile and add the following line to it:
export PATH=<path_to_android_sdk>/platform-tools:<path_to_android_sdk>/tools:$PATH
where <path_to_android_sdk> is to be replaced with the path to your SDK. For example: "/Users/me/android-sdk-mac_86/platform-tools"

Step 0
The first step is install Android SDK: https://developer.android.com/studio
I don't like the default configurations. I installed SDK in this folder:
/Users/<Username>/Android\ SDK
ℹ️ The default path is
$HOME/Library/Android/sdk
Step 1
The next command open your bash or zshrc configuration file:
Bash profile:
vim ~/.bash_profile
If you use zsh:
vim ~/.zshrc
Step 2
You're ready to update your configurations:
# File: .bash_profile | .zshrc
# Custom path to Android SDK folder.
# If you use the default configuration please change ANDROID_HOME to $HOME/Library/Android/sdk
export ANDROID_HOME=/Users/<Username>/Android\ SDK
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
Step 3
Option 1:
Restart your terminal and you should be able to use android command
Option 2: source your bash or zsh profile.
Example: source ~/.bash_profile / source ~/.zshrc

I spent so much time trying to figure out, this steps helped me ( from http://docs.phonegap.com/en/2.2.0/guide_getting-started_android_index.md.html )
You need to execute your .bash_profile to update your PATH.
Set up your PATH environment variable on Mac OS
Open the Terminal program (this is in your Applications/Utilites folder by default).
Run the following command
touch ~/.bash_profile; open ~/.bash_profile
This will open the file in the your default text editor.
You need to add the path to your Android SDK platform-tools and tools directory. In my example I will use "/Development/android-sdk-macosx" as the directory the SDK is installed in. Add the following line:
export PATH=${PATH}:/Development/android-sdk-macosx/platform-tools:/Development/android-sdk-macosx/tools
Save the file and quit the text editor. Execute your .bash_profile to update your PATH:
source ~/.bash_profile
Now every time you open the Terminal program you PATH will included the Android SDK.

Problem Solved For Android Studio Users:
I am using Mac OS X Elcapitan version 10.11.X.
Under my home directory I found .bash_profile.save file. I opened that file using sublime (you can use any other editor). Then I added this line
export PATH=${PATH}:/Users/UserName/Library/Android/sdk/platform-tools:/Users/UserName/Library/Android/sdk/tools
Replace "UserName" with your UserName.
open terminal then run
source ~/.bash_profile
here you go.

First add these lines to your ~/.bashrc file:
export ANDROID_HOME=${HOME}/Library/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
then:
source ~/.bashrc

export PATH="/Users/me/Library/Android/sdk/platform-tools/":"/Users/me/Library/Android/sdk/tools/":$PATH
Worked for me

Add the following lines into ~/.bash_profile and source ~/.bash_profile
export ANDROID_HOME=/Users/macbook/Library/Android/sdk/
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
This is working for me

Update the path.
Open the Terminal program from Spotlight. Run the following command:
touch ~/.bash_profile; open ~/.bash_profile
Then save following code
export PATH=${PATH}:/android-sdk-macosx/platform-tools:/Development/android-sdk-macosx/tools
For my case, path is
export PATH=/Users/<user-name>/Development/android-sdk-macosx/platform-tools:/Users/<user-name>/Development/android-sdk-macosx/tools:$PATH
Save the file and quit the text editor. Execute your .bash_profile to update your PATH:
source ~/.bash_profile
Then run adb.

This is the issue because of you didn't give proper android sdk path variable in .bash_profile. for this you must follow the below steps.
1. Check android sdk path: for this you should open android studio->preferences and click on Android SDK in newly open window in that look for Android SDK location textfield in that you can find path of Android SDK. For me it shows like: /Users/<your_name>/Library/Android/sdk. here <your_name> is name of your home directory.
2. Open your terminal enter cd ~ command.
3. and enter vi .bash_profile.
4. In vi editor enter following
export ANDROID_HOME=/Users/Murali/Library/Android/sdk
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
Save it by press esc button and enter :wq.
5. After this close your terminal and open it again.
6. To apply all your changes in .bash_profile enter following command
source .bash_profile.
7. Enter android command. Hope this now working fine :-)

Update the path.
Open the Terminal program from Spotlight. Run the following command:
touch ~/.zshrc (or ~/.bash_profile) ; open ~/.zshrc (or ~/.bash_profile)
Then save following code
export AAPT_HOME=/Users/****/Library/Android/sdk/build-tools/31.0.0
export PATH=$PATH:$AAPT_HOME
Save the file and quit the text editor. Execute your .zshrc (or .bash_profile) to update your PATH:
source ~/.zshrc (or ~/.bash_profile)

Related

android target: android: command failed with exit code enoent Meteor

I have meteor project and I try to start it on my mobile device. It starts successfully if I run project on my windows pc and I'm getting this error(error in title) when I try to start it in my linux(ubuntu) pc. Did everything from mobile tutorial on official site of meteor and still can't start a project. I saw a lot of almost the same questions but they hadn't correct answers for me.
Try run your this command in your terminal:
echo $ANDROID_HOME
it should return something like this
/home/ivan133/Android/Sdk
If it returns empty string execute these commands and build again
export ANDROID_HOME=${HOME}/Android/Sdk
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
Next, it would be nice to add it to your ./bashrc (if you're using bash)
Just open ~/.bashrc with text editor and copy the strings to the end
I had followed the above instructions to no avail. Realized the /tools folder was somehow missing from the /sdk folder. Also it's sdk not Sdk for me.
Complete instructions:
Double check where your sdk folder is. Should be something like:
/User/example-user/Library/Android/sdk
Visit https://developer.android.com/studio?pkg=tools and download the SDK tools package
Extract the contents of that. Should result in a directory named tools
run open /User/example-user/Library/Android/sdk
Place the tools folder into /sdk (so just to be clear, it will be at /User/example-user/Library/Android/sdk/tools
You can then do the following:
export ANDROID_HOME=${HOME}/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
meteor remove-platform android
meteor add-platform android
To check the environment variables first
env
If env variable not available means open or create .zprofile or .zshrc file in your HOME folder.
touch ~/.zprofile; open ~/.zprofile
or
touch ~/.zshrc; open ~/.zshrc
Added these lines
export ANDROID_HOME=${HOME}/Library/Android/sdk
export ANDROID_SDK_ROOT=${HOME}/Library/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
After added that variable and run this below comment
source ~/.zprofile
or
source ~/.zshrc
and it started to work
Now again to verify to type comment line
env
Check the env variable availability
I added these lines
export ANDROID_HOME=${HOME}/Android/Sdk
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
to ~/.zshrc file
and it started to work

Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions

I am MAC OS X Yosemite I have done all the export tutorial to set the android_home but non of it working for me
Making sure ANDROID_HOME is exported and adding the SDK tool directories to PATH should be more than enough to get you going.
Using the terminal
# First, we make sure we have a newline at the end of the .bash_profile
echo >> /Users/abdi/.bash_profile
# We set the ANDROID_HOME value in the .bash_profile
echo "export ANDROID_HOME=/Users/abdi/adt/sdk" >> /Users/abdi/.bash_profile
# We alter the PATH value a bit as well
echo "export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools" >> /Users/abdi/.bash_profile
# We then tell the terminal to update all the things
. /Users/abdi/.bash_profile
Using a GUI (mostly)
You can also open the .bash_profile file in TextEdit using the open -e /Users/abdi/.bash_profile command. If you get some errors about missing files, try running touch /Users/abdi/.bash_profile and retry the open command. In the file that opens, add the following lines at the end.
export ANDROID_HOME=/Users/abdi/adt/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Running . /Users/abdi/.bash_profile as in the terminal version after that should get you fully set up.
First need to set the ANDROID_HOME directory
look into your android-sdk-linux(mac) directory and look for 'android' executable file, generally it will exists under 'tools' directory
so edit your .bashrc from home folder
and add this line down there
export ANDROID_HOME=~/android-sdk-linux
PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Once done, exit your console and run your command again
You could expect an error saying " Please install Android target "android-19" " if it is not set yet.
you may fix that running "android" command and selecting "Android 4.4.2 API 19" to install.
And afterwards, don't forget to give ample permission to directory where the application resides.
I had the same problem. Luckily it is easily fixable. Just follow the next few steps (Command-line from terminal).
Open the bash_profile file using command line arguments with -
vi ~/.bash_profile
OR
It is possible to open bash_profile in TextEdit and make changes there. Use the following command to do this -
open -a "TextEdit" .bash_profile
Check if ANDROID_HOME has been set in this file. If it has been already set, delete it (probably wrong). Also check if PATH in this file has any reference to tools or platform-tools (of the android sdk). You'd be better off deleting these before you start typing the following commands.
Set ANDROID_HOME correctly using the following command
export ANDROID_HOME=/Users/adarsh/android-sdk-macosx
^this is my command because I installed it in that location. Please replace "adarsh" with your username and "android-sdk-manager" with the name of your android sdk folder that you downloaded. Do not copy-paste this command.
For example, if your username is "John" and you the android sdk folder you downloaded and installed is in "Downloads" and you changed your folder name to "sdk", then your command would be -
export ANDROID_HOME=/Users/John/Downloads/sdk
Set PATH with the following command
export PATH=$ANDROID_HOME/tools:$PATH
Refresh your bash_profile to set all the changes we just made by typing the command
source ~/.bash_profile
You should be good to go now and begin developing with ionic!Hope this helps. Cheers.
One source of this problem comes from sudo. If you're sure you've set $ANDROID_HOME correctly then try the following:
sudo visudo
then add
Defaults env_keep += "ANDROID_HOME"
Make sure the env variable you exported is ANDROID_HOME and not android_home (case sensitive).
After you export, test it by typing
> echo $ANDROID_HOME
The result should point to the dir where you installed the SDK.
Last but not least edit your /etc/paths to add dirs $ANDROID_HOME/platform-tools or /Users/abdi/adt/sdk/platform-tools and $ANDROID_HOME/tools or /Users/abdi/adt/sdk/tools to the list. Save file. You might need to edit this file as admin if need be. Close terminal and then Open new terminal. Then type
> echo $PATH
to check if the path is updated.
And then voila, when you type
> which android
you should see the correct path to the binary returned which in your case is /Users/abdi/adt/sdk/tools/android. you should be all set now.
None of the solutions here solved my problem completely. My Node version was little bit old and ionic was giving a warning to upgrade node. After upgrading Node, I had to delete the project and again create the project, then perform all the steps. Hope this helps somebody.

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

I tried to make a .jar file from a cloned project:
android update project -p .
but got the error:
android: command not found
I tried to set path to Android SDK, but it didn't help:
export ANDROID_HOME=D:\java\android-sdk
export PATH=$ANDROID_HOME\tools:$PATH
export PATH=$ANDROID_HOME\platform-tools:$PATH
Is it possible to solve this problem?
UPD:
I'm using Git Shell from this software: http://git-scm.com/download/win
Finding-android-sdk-on-mac-and-adding-to-path
Finding Android SDK on Mac and adding to PATH
To fix
android: command not found error
follow two easy steps (Linux and Mac):
1) Export your Android Sdk path to the ANDROID_HOME variable
$ export ANDROID_HOME=~/Android/Sdk
(change "~" to "$HOME" on Mac)
2) Export Sdk tools path to the PATH variable
$ export PATH=$ANDROID_HOME/tools:$PATH
That's it! run
android
command again to make sure it works properly.
You have to configure ANDROID_HOME environment variable.
For Mac Run this command
export ANDROID_HOME=~/Library/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
For Windows
Go to Control Panel → System and Security → System → Change settings → Advanced System Settings → Environment variables → New, then enter the path to your Android SDK.
Variable name = ANDROID_HOME
Variable path = your android sdk path.
If you run commands from windows shell (cmd.exe) you should add D:\java\android-sdk\tools and D:\java\android-sdk\platform-tools to your path via computer properties dialog.
If you run on Cygwin try export PATH=/cygdrive/d/java/android-sdk/tools:/cygdrive/d/java/android-sdk/platform-tools:${PATH}.
This worked for me on ubuntu
Edit the bashrc using nano:
nano ~/.bashrc
By adding the following to the end of the file:
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
Exiting the nano editor:
ctrl + x , then type Y, then hit the enter key to save the changes to the .basrc file and to exit the nano editor.
The above steps would ensure that your changes remains after the terminal closes. Note, for the android command to work ensure to close the terminal and reopen a new one.

Trying to add adb to PATH variable OSX

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"

Categories

Resources