8

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.

nilkash
  • 7,120
  • 30
  • 91
  • 165

6 Answers6

17

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?

Community
  • 1
  • 1
Amit Gupta
  • 8,604
  • 1
  • 22
  • 32
  • 2
    I tried your solution. I added you line into my bash_profile file. And tried android command on command line but still same error. Why it is so ? Need Help. – nilkash Oct 23 '13 at 16:40
  • sir I did exactly same. In bashrc file I add those lines after that I close terminal and also start new terminal but still same problem. May I restart mt machine ? – nilkash Oct 23 '13 at 16:54
  • in bashrc need to add not export PATH=${PATH}:~/android-sdk-linux/tools but export PATH=${PATH}:~/Downloads/android-sdk-linux/tools same for platform tools – socm_ Sep 07 '14 at 10:06
  • 1
    thanks for detailed answer, hence up-vote. There are lot of answers on this and other similar questions on this site, like 'define paths' or 'add paths'; but where? only you mentioned that it's in 'bashrc' and also with how to edit it. So request to all to give detailed answer like this. Thanks again. – Shirish Herwade Oct 07 '14 at 11:51
  • Reload `~/.bashrc`: `. ~/.bashrc` or `source ~/.bashrc` [*details](http://stackoverflow.com/questions/2518127/how-do-i-reload-bashrc-without-logging-out-and-back-in) – Tomblarom Sep 17 '15 at 16:00
11

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! ;)

Prakash R
  • 409
  • 2
  • 13
vladymy
  • 349
  • 2
  • 6
4

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!

Ivan V
  • 2,934
  • 3
  • 23
  • 36
1

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

P-RAD
  • 963
  • 2
  • 13
  • 32
0

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.

Zax
  • 2,612
  • 6
  • 44
  • 69
  • 1
    I tried your solution. I added above path in my profile file but still same problem. Need Help. – nilkash Oct 23 '13 at 16:43
0

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

Khaled Awad
  • 1,054
  • 7
  • 22