user1269586
user1269586

Reputation: 370

Add Android support to Cordova project

I have the following error while I'm building app on android in my Cordova project (I have the Android SDK downloaded). I'm running on Mac OS X

Creating android project...

/Users/me/.cordova/lib/android/cordova/3.5.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.
at /Users/me/.cordova/lib/android/cordova/3.5.0/bin/lib/check_reqs.js:85:29
at _rejected (/Users/me/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:808:24)
at /Users/me/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:834:30
at Promise.when (/Users/me/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/Users/me/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:752:41)
at /Users/me/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:574:44
at flush (/Users/me/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:419:13)
Error: /Users/me/.cordova/lib/android/cordova/3.5.0/bin/create: Command failed with exit code 8
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:755:16)
at Process.ChildProcess._handle.onexit (child_process.js:822:5)

Anyone know how to solve this issue? Thanks

Upvotes: 1

Views: 1179

Answers (1)

QuickFix
QuickFix

Reputation: 11721

Ok, my bad the SDK is installed. Have you installed the SDK for API 19?

  • Run the android sdk manager using the android command
  • Find the group "Android 4.4.2 (API 19)
  • Check the line "SDK pkatform"

Cordova 3.5 uses SDK 19 as target sdk (you can change it by editing androidmanifest.xml), so it's a requirement but that's not clearly explained and the error message is not clear either.

If you want to avoid a long time of downloading useless stuff, I would recommend you to uncheck everything about Android Wear (Android 4.4W) and Android L in the sdk manager before clicking the Install button.

All you really need is the SDK platform that matches with API 19, Android SDK tools, Android SDK platform tools, Android SDK Build-tools and maybe USB driver and Android support Library. Everything else can be safely unchecked if you want to save space/time.

When you get errors with android and cordova, there's a script you can try to get more details on the error. On OSX+cordova 3.5, it should be something like

$HOME/.cordova/lib/android/cordova/3.5.0/bin/check_reqs

To install apache ant and add it to your path, update your .bash.profile :

export ANDROID_HOME="/Users/me/adt-bundle/sdk"
export ANT_HOME="/Users/me/apache-ant"
export PATH="$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$ANT_HOME/bin"

Upvotes: 2

Related Questions