16

I'm struggling with my phonegap setup and building my first app.

I created a hello1 project. I added the android project

Platform android already added

Now when I run the cordova build, I get the error -

Error: Please install Android target: "android-22"

I do not have android-22. I do have android-19. I want my project to be built with android-19. How can I make that happen?

I had android-22 which I uninstalled (for fixing a bigger problem). I do not understand which file should I be making a change in for this to work. The project.properties in the project comes after this step and it automatically contains the target as android-22.

I have added my env variables correctly. C:\Users\user\android-sdks\platform-tools;C:\Users\user\android-sdks\tools

It doesn't help. This is just part of a bigger problem that I'm trying to debug. Please help.

peterh
  • 11,875
  • 18
  • 85
  • 108
Arvind
  • 169
  • 1
  • 1
  • 4
  • 1
    You need to change the targed sdk from 22 to 19 . What IDE are you using ? If eclipse, please check ; http://stackoverflow.com/questions/3342739/how-to-change-target-build-on-android-project – shamaleyte May 04 '15 at 11:22

6 Answers6

24

For SDK 21 ("android-21")

$ cordova platforms remove android
$ cordova platforms add android@3.7.1

For SDK 22 (Android 4.1.1, "android-22")

$ cordova platforms remove android
$ cordova platforms add android@4.1.1

More info: https://cordova.apache.org/announcements/2015/07/21/cordova-android-4.1.0.html

Honza
  • 974
  • 10
  • 18
7

Change these two. I din't try it for lower versions but this worked for me in upper versions

target=android-22<br>

This should be changed in two files like below:

target=android-19<br>

Location of the two files:

myApp/platforms/android/project.properties
myApp/platforms/android/CordovaLib/project.properties

Shuvo Habib
  • 2,035
  • 1
  • 20
  • 25
5

I am using cordova 3.5.0 which by default has target sdk as 19. You can install cordova 3.5.0 using

npm install -g cordova@3.5.0-0.2.6

For other versions of Cordova if you want to manually edit it you have to change this in AndroidManifest.xml file present in yourapplication/platfomrs/android.

<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" />
kumar
  • 1,814
  • 1
  • 24
  • 35
  • Thanks Kumar. I was using Cordova 5.0.0 and just realised that I get 22 as the default target. I will change that will the command that you posted. Helps. – Arvind May 04 '15 at 13:08
  • @Arvind accept the correct answer once you verify it :). – kumar May 05 '15 at 02:37
4

My problem got solved after installing SDK Platform of Andriod 5.1.1 (API 22) from Andriod Manager.

Manoj
  • 397
  • 2
  • 6
2

Steps:

  • $ /Users/username/Library/Android/sdk/tools/android
  • Install Android 5.1.1 (API 22)
  • $ cordova platforms add android@4.4.2
  • $ cordova build --release android

It works for me.

jruzafa
  • 4,156
  • 1
  • 24
  • 26
1
$ cordova platforms remove android
$ cordova platforms add android@3.7.1
user2226755
  • 12,494
  • 5
  • 50
  • 73