7

There are many questions here regarding problems running "cordova add platform android" command. I've tried each purposed solution and none have helped me.

Error message:

~/sandbox/hello$ cordova platform add android
Creating android project...

/home/acras/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:126
                    throw e;
                          ^
Error: Please install Android target 19 (the Android newest SDK). Make sure you have the latest Android tools installed as well. Run "android" from your command-line to install/update any missing SDKs or tools.
    at /home/acras/.cordova/lib/android/cordova/3.5.0/bin/lib/check_reqs.js:80:29
    at _fulfilled (/home/acras/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:798:54)
    at self.promiseDispatch.done (/home/acras/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:827:30)
    at Promise.promise.promiseDispatch (/home/acras/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:760:13)
    at /home/acras/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:574:44
    at flush (/home/acras/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:108:17)
    at process._tickCallback (node.js:415:13)
Error: /home/acras/.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.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:743:16)
    at Process.ChildProcess._handle.onexit (child_process.js:810:5)

I did what the error message tells me (run android and installed all packages) but the error persists.

PATH: Android SDK home, tools and platform-tools are in the path

In the platforms folder inside android sdk I have only android-20 and android-L folders.

I guess if I add android-19 OR make cordova want android-20 will solve my problem. What should I do to achieve both options?

Thank you

Ricardo Acras
  • 35,784
  • 16
  • 71
  • 112

3 Answers3

6

The current Cordova (4.1.2) only wants to build against API v19

> cordova build android
Running command: /Users/Duncan/Documents/Work/rescyoume/cordova/platforms/android/cordova/build 
[Error: Please install Android target "android-19".
Hint: Run "android" from your command-line to open the SDK manager.]

To install v19, run android as it suggests and then, in the GUI that opens, select Android 4.4.2 (API 19)/SDK Platform in the tree and click the Install packages... button.

Duncan McGregor
  • 17,665
  • 12
  • 64
  • 118
1

You need to download Android 4.4.2(API 19) because target API is set to 19 in android manifest file. Either change it to the API that you have already downloaded or download API 19

In terminal type the command

$ android

this will open the Android SDK manager. Check the API 19 SDK Platform checkbox and download it.

Now when you type command

$ cordova platform add android

should work fine.

Prashant_M
  • 2,868
  • 1
  • 31
  • 24
-2

If are you using Linux,

  • Install ant:
    sudo apt-get install ant
  • Export the correct sdk path:
    export PATH=${PATH}:/<sdk path>/sdk/platform-tools:/<sdk path>/sdk/tools
Teemu Leisti
  • 3,750
  • 2
  • 30
  • 39