Abhishek Bedi
Abhishek Bedi

Reputation: 5451

Phonegap/Cordova: Error while building for android platform

phonegap build android

[phonegap] adding the Android platform...

[error] An error occured during creation of android sub-project.

/Users/MYMacbook/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:126 throw e; ^ 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.

I have the latest sdk updated. yet the error haunts again and again . Any idea?

Upvotes: 1

Views: 364

Answers (3)

JaKXz
JaKXz

Reputation: 1651

From the error message, it looks like you need to add the Android home tools and platform tools folders to your $PATH, i.e.

export ANDROID_HOME="/path/to/your/sdk-folder" # e.g. "/Applications/Android\ Studio.app/sdk"
export PATH="$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools"

and then run source ~/.bash_profile or source ~/.profile based on which one you used.

Then you'll need to run phonegap install android before you do build.

Finally, it would probably help you to update phonegap/cordova; I'm guessing you have it installed via npm so run (fix sudo if necessary):

npm cache clean
npm update -g

Android platform guide for reference.

Upvotes: 3

E. Valencia
E. Valencia

Reputation: 457

it looks like a path issue, so Phonegap CLI scripts cannot reach to the Android toolchain.

Have you followed the Phonegap Android guide here? Most importantly this part:

export PATH=${PATH}:/Development/adt-bundle/sdk/platform-tools:/Development/adt-bundle/sdk/tools

Best.

Upvotes: 3

Related Questions