4

I have installed the latest cordova. The version is 4.3.0. I created an empty Cordova project:

cordova create test com.test Test

I then add the platform:

cordova platform add android

I built the project with:

cordova build android

But i always get:

[Error: Please install Android target: "android-21".

Hint: Open the SDK manager by running: C:\Program\ Files\     (x86)\Android\android-studio\sdk\tools\android.BAT
You will require:
1. "SDK Platform" for android-21
2. "Android SDK Platform-tools (latest)
3. "Android SDK Build-tools" (latest)]

So i ran "android" to confirm I have latest SDK installed: enter image description here

I then tried changing the target android sdk to be 19 so in AndroidManifest.xml I changed:

<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="21" />

to:

<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" />

I ran the build command again, and I still get the exact same error. This is driving me nuts. Anyone have any ideas? I've built many many cordova projects on this same PC and have never seen this problem before.

Mark
  • 4,428
  • 14
  • 60
  • 116
  • Are you opening programFiles/Android sdk manager or android-studio sdk manager? They can be installed separatelly I think. – Majky Mar 12 '15 at 15:58
  • Your snapshot shows android api 16, how is that supposed to be the latest? If your android sdk manager doesn't show you any SDK more recent I'd suggest you re-install android sdk. – QuickFix Mar 13 '15 at 10:38

4 Answers4

2

I had the same problem and I fixed it appending to the PATH environment variable the following Android SDK folders:

  • C:\Program Files\Android\sdk\tools
  • C:\Program Files\Android\sdk\platform-tools
  • Thanks, that fixed the problem for me. As I did install the sdk manager on a different partition, it was not able to find it by himself. – boyomarinov Nov 15 '15 at 16:07
2

not sure if this the place to post this answer but I spend over an hour trying to find why "cordova build" was demanding 22, when I had 23 installed so I thought I'd share:

In my case the project was created before I did and update was was targeting android-22 changing the line: "target=android-22" to "target=android-23"

in the following files allowed a build: \platforms\android\project.properties \platforms\android\CordovaLib\project.properties

gion_13
  • 41,171
  • 10
  • 96
  • 108
Udog8
  • 21
  • 1
2

I had the same problem - it occurs if you only download the Android SDK but have not yet started the android command and installed updates. In this case Cordova is telling you to install/update the SDK for Android's API version 23 (specified as "android-23" in your platforms/android/project.properties file).

Solution: run android[*] and select the corresponding:

  • Under Tools:
    • "Android SDK Platform-tools 23.1
    • "Android SDK Build-tools 23.1
  • Under Android 6.0 (API 23)
    • SDK Platform

Install these and re-run cordova build android and it should work.

[*] Assuming your sdk/tools path is on your system PATH (see here)

Community
  • 1
  • 1
Marc
  • 13,011
  • 11
  • 78
  • 98
1

Well you need to update Android SDK tools and Android SDK platform-tools first. Then you will get the update for API 21

Ishaan Puniani
  • 646
  • 2
  • 10
  • 23