I am using Ubuntu 14.04 Trusty Tahr, and I downloaded Android Studio with the umake tool provided by Ubuntu. This downloaded Android Studio at /root/tools/android/android-studio,
and platform-tools and all other tools at /root/Android/Sdk/.
Android Studio on my PC is working just fine, and I am able to create an application and also run it on my mobile phone using it. But I want command line access to the tools and so I want to add them to the environment path.
To add them to environment path, I did this:
nano ~/.bashrcAnd added the following lines-
export PATH=${PATH}:/root/Android/Sdk/platform-tools export PATH=${PATH}:/root/Android/Sdk/build-toolsBut this dosen't work. When I give the command adb from a terminal, it dosen't seem to invoke the adb tools from the platform-tools folder. Instead it tells me to install android-tools-adb.
I am however being able to cd into platform-tools, and run adb and other tools from there, but I don't want to do that again and again. Also, how can I add Android Studio to my PATH so that I don't have to cd into its bin/ directory again and again?
Thank you very much in advance.
15 Answers
This worked for me
export PATH=$PATH:$HOME"/android-sdk-linux/platform-tools" If you install Android SDK through Android Studio (or any other way that put you Android SDK folder under this path), execute this line:
export PATH=$PATH:$HOME"/Android/Sdk/platform-tools" I added this line to the bottom of my .bashrc and it works.
export PATH=/home/[myusername]/android-sdk-linux/platform-tools:$PATH
source ~/.bashrc #To update the bashrc with the changes in the current tabI don't understand the PATH=${PATH} syntax in your example, so I can't comment on whether it's correct or not, but you could try the syntax I used.
I installed Android Studio via snap. So I had to add the platform-tools folder path to the .bashrc file.
If you use visual studio code as editor type this in the terminal
code ~/.bashrc
It will open the visual studio code and the .bashrc file is opened in it. Go to the bottom of the file and add the following export,
# Android Path if [ -d "$HOME/Android/Sdk/platform-tools" ] ; then export PATH="$HOME/Android/Sdk/platform-tools:$PATH" fi
Note: Leave and empty line at the end of .bashrc file. So the shell program knows it is the end of file (EOF).
Saved the .bashrc file and quit visual studio code
Go to Terminal and source the updated .bashrc file
source ~/.bashrc There are 2 common ways to set your PATH environment variable in ~/.bashrc. We may mess them up (I did).
- Method 1:
export PATH="~/Android/Sdk/platform-tools:$PATH" - Method 2:
PATH=~/Android/Sdk/platform-tools:$PATH
The export method requires to put the PATH value between quotes and the second does not.
I recommend the second method - set the PATH variable directly - because we may not have to worried about quote(s).