Error: Android Target "android-22"

Hello everybody,

I know its a very frecuently question in the forum, but I couldn’t find ANY good answer to my problem.

When I create a new project and add android ($ionic platform add android), and when it’s initializing the Android, says automatically:
Android target: android-22

I cannot find any way to tell ionic (or cordova in this case) to use another lower API level, as 19 for instance.

  • I have PATH’s working properly.
  • I have API 19 downloaded in Android SDK (also I can see it in …/Android/SDK/platforms folder).
  • I DON’T have downloaded the API 22, coz Android 5.1.1 it’s not compatible with the most used Android 4.X.

I have modified several files within my project:

  • ./platform/androind/AndroidManifest.xml // And changed < android:targetSdkVersion=“19”>
    How Can I Specify The “Android API Level” of app project?

  • And files that Im sure makes nosense I modify coz they are modified automatically later:
    (platforms/android/project.properties // platforms/android/CordovaLib/project.properties)

  • And also the config.xml in the project folder.

All comes when I type: (ionic build android) and shows:
(Error: Please install Android target: “android-22”.)

Sorry again for this repeated question in forums, but none of the answers found worked to me.

Thank you in advance, best regards.

config.xml is the file where you should put min and target sdk, if it does not work maybe you use a plugin that requires another SDK.

I’m not using any plugin, just creating a new project with ‘ionic start NewApp’ and automatically looks for android-22 which I don’t want to have installed.

config.xml: " preference name=“android-minSdkVersion” value=“16” "

But again, when I buid the app (just created, empty, after add platform) ’ ionic build android ', starts looking for android-22, when I have installed a prev. one (API 19 for instance).

I installed API 22, but just to keep working, while I solve, or learn how to handle this.

Thanks a lot for your answer!

1 Like

For me, it works fine, I have in config.xml

  <platform name="android">
    <preference name="android-targetSdkVersion" value="19"/>
    <preference name="android-minSdkVersion" value="19"/>
1 Like

Hello @ButterySAM777
I think this happens to update ionic, surely you run:
npm i -g ionic
or downloaded the latest version of ionic => 1.6.4

Now you add the platform:

ionic platform add android

This will associate your app to the api 22, as shown in the file
you_app/platform/androind /androidManifest.xml
tag:

<android: targetSdkVersion="22">

My questions:
In reality this is affecting the operation of the app in previous versions (API 4.4.2- 19)?
Have you been tested on devices with android version (API 4.4.2- 19)?

Regards

Hello all, and sorry for not answering back before.
Left this issue for some time, and continued working, and studying the famework.

I’ve just formated my computer and installed everything from scratch, from zero.

Android SDK Manager: I just added Android 4.1.2 (API 16)

Ionic: ionic start project // ionic add android // ionic build android

When I just do build, the terminal shows:

add to body class: platform-android Running command: cmd "/s /c "C:\Users\SAM\Documents\ionic-projects\BORRAPP\platforms\android\cordova\build.bat"" [Error: Please install Android target: "android-22".

1- Yes, I have added
<preference name="android-targetSdkVersion" value="16"/>
to the config.xml file.

2- AndroidManifest.xml has:
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="16" />

The main problem I find is that I cannot build the app for the minimum Andorid 4.X version. Or when I built it before having the API-22 installed, I couldn’t install it to a lower version Android I have.

I was told, I should create my Android APP, when I wanted to work directly with its SDK, that I should build an app for the smaller version of Android API, to let it be more compatible with a wider range of Android devices. So that’s my point. I wanted be able to control that easily.

Thanks a lot for your help and patience.

Best regards.

Hey,

try edit the file
platforms

android


AndroidManifest.xml
project.properties

then change the line
target=android-24
android.library.reference.1=CordovaLib

Hope it helps. Cheers!