17

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

Mark Korzhov
  • 2,109
  • 11
  • 31
  • 63

4 Answers4

24

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.

Abhishek Bedi
  • 5,205
  • 2
  • 36
  • 62
Ivan V
  • 3,024
  • 4
  • 26
  • 36
  • This worked for me, though my actual path variables were a little different (`$Home/Developer/android-sdk-macosx`). – justinraczak Sep 17 '15 at 23:51
  • @jose920405 Did you try $HOME instead of ~ for android sdk path? It worked on my mac. – Ivan V Feb 23 '17 at 12:39
  • For people over here who are still struggling, Iran V gave hints and it would better if you locate your Android SDK folder by yourself. Like for me it was located in /Users/bachiri/Library/Android/sdk and normally the android executable file should be in the tools folder. literally, the exact path that I should add to to the $PATH variable is /Users/bachiri/Library/Android/sdk/tools =>$HOME/Library/Android/sdk/tools – Bachiri Taoufiq Abderrahman Sep 06 '18 at 13:37
13

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.

7

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}.

Anton Savin
  • 40,838
  • 8
  • 54
  • 90
3

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.

David Charles
  • 537
  • 6
  • 11