50

I am trying to run the command in ubuntu

android update project --path .

However I am getting a android:command not found error.

I assume this is something to do with the path which I learnt on here the other day? I was just wondering, what do variable do I need to add (Android I assume) and what do I need to point it too.

A-Sharabiani
  • 17,750
  • 17
  • 113
  • 128
Biscuit128
  • 5,218
  • 22
  • 89
  • 149

9 Answers9

132

On MacOS/Linux, define the path to wherever you installed your SDK as ANDROID_HOME:

MacOS

$ export ANDROID_HOME=/Applications/android-sdk-macosx

If you installed Android Studio, the value will need to be

export ANDROID_HOME=$HOME/Library/Android/sdk

Linux

$ export ANDROID_HOME=~/android-sdk-linux

Then add the paths to the platform-tools and tools sub-directories (Same on MacOS/Linux).

export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH

You should now be able to run android from the shell.

If none of the suggested ANDROID_HOME paths above are valid, you can find the (uniquely and consistently named) platform-tools folder via:

find / -name platform-tools 2>/dev/null

Whatever path that returns will need to be trimmed down to end with either sdk, android-sdk-linux, or android-sdk-macosx.

Bruno Bronosky
  • 66,273
  • 12
  • 162
  • 149
Festus Tamakloe
  • 11,231
  • 9
  • 53
  • 65
26

Another possibility is simply that your "android" file is not executable. Navigate to the tools path in terminal and then make it executable by:
chmod 777 android
Then you can run:
./android sdk
It's what worked for me.

possumkeys
  • 538
  • 5
  • 14
7

Assuming that you have set ANDROID_HOME to point to the sdk install, you should add $ANDROID_HOME/tools and $ANDROID_HOME/platform-tools to your PATH.

Erich Douglass
  • 51,744
  • 11
  • 75
  • 60
3

Sometimes even after you add your android_sdk/ dir path from command line it still doesn't work and gives the command not found error, in that case follow these steps. I ran through this issue myself and i tried all the above steps and none worked so i thought i should share and perhaps that might help somebody.
( android-sdk-linux is the name of android sdk library which you have extracted ).

1) Open the bashrc file from command line

gedit ~/.bashrc

2) Add following lines at the top.

export PATH=${PATH}:~/android-sdk-linux/tools
export PATH=${PATH}:~/android-sdk-linux/platform-tools

3) Log out of the system and log back in. Type Ctrl + Alt + T to open command line and type android to launch the software.

Mosh Feu
  • 28,354
  • 16
  • 88
  • 135
Abdul Mannan
  • 1,072
  • 12
  • 19
  • Logging out & back in is required to get the OS to read .bashrc into memory. As a shortcut, you can just tell the OS to read the file again with: source ~/.bashrc (same as) . ~/.bashrc (both assuming the file is in your home directory ~/ ) – Chaos7703 Sep 02 '18 at 19:42
  • source ~/.bashrc will update the environment vars in the terminal/tab you run it in. If you are working in another tab (that was already open when you ran source ~/.bashrc), then you have to run it there too or open a new tab so that it has the updated references. – Chaos7703 Sep 02 '18 at 20:31
2

After installing Android studio. Create or edit your ~/.bashrc file and add the following lines:

export ANDROID_HOME=~/Android/Sdk
export PATH=${PATH}:${ANDROID_HOME}/tools

and reload .bashrc

source ~/.bashrc
Karl Adler
  • 15,780
  • 10
  • 70
  • 88
1

That's because your platforms and platform-tools are not in the PATH environment variable. You can run the adb command with path-to-adb/adb or add platforms and platform-tools to PATH and run typing only adb

This is my path environment variable:

PATH=/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.5.3:/opt/android-sdk-update-manager/tools:/opt/android-sdk-update-manager/platform-tools
Blackbelt
  • 156,034
  • 29
  • 297
  • 305
1

For Mac, go into your home directory by typing cd ~, and then type vi .bash_profile, This file might be empty or just created, and this is not a problem.

To edit the file, press i on your keyboard and inside the file, type the following path:

export PATH="/Users/YOUR-USERNAME-HERE/Library/Android/sdk/platform-tools":$PATH
export PATH="/Users/YOUR-USERNAME-HERE/Library/Android/sdk/tools":$PATH

When you are done, press esc, and again press shift : and type wq. Okay, now you saved your file. Now, quit terminal and re-launch, and try typing:

adb -h
android -h

If both commands are giving you output, it means everything works fine.

Not: We used vi command to edit the file. If you got confused with this command, you can also try nano for editing the file.

cyonder
  • 852
  • 1
  • 15
  • 36
0

android is now inside android-sdks/tools

if you are using mac, you may set your .bash_profile to include it.

PATH=$PATH:[android-sdks]/platform-tools:[android-sdks]/tools
James Tan
  • 1,336
  • 1
  • 14
  • 32
0
  1. Uninstall cask android-platform-tools

    brew cask uninstall android-platform-tools
    
  2. Install it using Android Studio