18

I am trying to add android as a cordova platform so that I can build apps with phonegap. When I tried to add android thus:

$ cordova platform add android

I received this error message:

[Error: The command android failed. Make sure you have the latest Android SDK installed, and the android command (inside the tools/ folder) added to your path. Output: /bin/sh: android: command not found ]

I do have the latest Android SDK installed, so I suppose I need to add android to my path. I've googled on how to do that, and searched this forum, but I have little knowledge of command line use and I don't understand the answers.

If someone could provide very simple steps to add android to my path, I would be most grateful.

Shekspir
  • 87
  • 2
  • 12
Jimmy Verner
  • 199
  • 1
  • 1
  • 4

7 Answers7

32

There's step-by-step instructions on the PhoneGap Doc's. Check it out here, and then go to Step 3B. I linked to the 2.8 version of PhoneGap since from a quick look it doesn't seem to explain how to set up PATH on the 3.0 version docs.

Drew B.
  • 1,145
  • 10
  • 15
8

I just figured this out. You need to use the path where your android tools are actually installed. Mine happen to be in the default location (and I'm using x64) so, /Applications/adtbundle name/

Just see for yourself!

see for yourself

Joel
  • 4,732
  • 9
  • 39
  • 54
user43633
  • 319
  • 3
  • 7
6

I was running into a rather silly problem here. The path that I cut and pasted had the adt-bundle listed as "adt-bundle" (as one might expect :)) but I never changed the name of the directory as it was downloaded, which was "adt-bundle-mac-x86_64-20131030."

Additionally, the path ($PATH) that I cut and pasted into my .bash_profile began with "/Development" when it should have begun with "~/Development" since the Development directory was in my home directory.

I don't know if anyone else might find this info useful, but it was a relief to me when I realized that I just needed to correct the paths I'd specified in .bash_profile.

flyingace
  • 1,707
  • 17
  • 24
2

Its very easy. Just Download the android SDK, later set the path android sdk having folder tools and platforms tools in the system variables. Now later the set the path of ANDROID_HOME in the user variable. That's it. Now you can add, run , build your android platform.

Nitin Agarwal
  • 943
  • 1
  • 13
  • 26
  • [The syntax is ANDROID_SDK_HOME](https://blogs.endjin.com/2013/06/android-device-manager-and-sdk-location/) – TombMedia Jun 06 '16 at 16:44
1

On MAC - I got this problem after installing Android Studio (it was working before).

I had to do:

touch ~/.bash_profile; open ~/.bash_profile

and then add the line

export PATH=$PATH:/Users/<USR>/Library/Android/sdk/tools

and restart terminal.

Elia Weiss
  • 8,324
  • 13
  • 70
  • 110
0

If you used Eclipse to install and manage Android SDK then do following:

Open Window->Android SDK Manager in Eclipse and in new window you will be able to see SDK Path on the top

Now you should include this path as ANDROID_HOME system variable and export /tools and /build-tools it to system PATH variable

On OS X you can include system variables like following:

In Terminal run nano ~/.bash_profile (because probably the .bash profile is not create yet, it will we created in root folder of your User)

In my case SDK path was '/Users/markusila/android-sdks'

Insert following code, but using your SDK path, into the editor opened

export ANDROID_HOME=/Users/YOUR_USER_NAME/android-sdks
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

Now simply run . ~/.bash_profile and changes will be included.

Mark Okhman
  • 564
  • 6
  • 13
0

In addition to the answers above, don't forget to update the file based in your favorite shell, for example:

ZSH:

 1. vi ~/.zshrc
 2. Considering that my Android SDK is in "/Users/wils/Library/Android/sdk/" and using vi as editor:
export PATH="/Users/wils/Library/Android/sdk/platform-tools:/Users/wils/Library/Android/sdk/tools:$PATH"
 3. Save
 4. source ~/.zshrc

BASH:

 1. vi ~/.bash_profile
 2. Considering that my Android SDK is in "/Users/wils/Library/Android/sdk/" and using vi as editor:
export PATH="/Users/wils/Library/Android/sdk/platform-tools:/Users/wils/Library/Android/sdk/tools:$PATH"
 3. Save
 4. source ~/.bash_profile

I hope it help somebody else. Piece \o/

Wils
  • 1,211
  • 17
  • 31