Sascuash
Sascuash

Reputation: 3831

Cordova error while adding android in mac

I'm working on a macbook and developing with cordova. Now, I want to create an Android apk, but, when I type cordova platform add android I get this:

Error: The command "android" failed. Make sure you have the latest Android SDK installed, and the "android" command (inside the tools/ folder) is added to your path.

Ok, this message should be very clear about what to do next, but don't know what to do. When I search I keep getting how to solve this in Windows and can't follow steps.

What (and how) should I do?

Thanks

EDIT:

I've already installed Android SDK when trying to compile apk.

More info:

As I couldn't install ANT, I uninstalled it: brew uninstall ant. But when brew install antagain I got:

$ brew install ant
==> Downloading http://www.apache.org/dyn/closer.cgi?path=ant/binaries/apache-ant-1.9.3-bin.tar.gz
==> Best Mirror http://apache.rediris.es/ant/binaries/apache-ant-1.9.3-bin.tar.gz

curl: (22) The requested URL returned error: 404 Not Found
Error: Failed to download resource "ant"
Download failed: http://apache.rediris.es/ant/binaries/apache-ant-1.9.3-bin.tar.gz

Upvotes: 1

Views: 1257

Answers (1)

Dawson Loudon
Dawson Loudon

Reputation: 6029

Some things to make sure you have completed before starting w/ Android:

Make sure ANT is installed:

Try ant --version, if command not found you need to install ANT.

The easiest way I have found is to use Homebrew. If you do not have homebrew installed, get it here

Once installed run

homebrew update
homebrew install ant

Unpack Android SDK:

Download and unpack the SDK package, place it in an easy to find location.

Then add the tools and platform-tools paths to your global PATH, like this:

vi ~/.bash_profile

add this line:

export PATH=/path/to/android/sdk/tools:/path/to/adnroid/sdk/platform-tools:$PATH

Exit the terminal and re open the terminal.

Now you should be able to run cordova platform add android in your project folder.

Upvotes: 1

Related Questions