How can I do to choose the API 22 with "cordova build android"?. (Cordova doesn't listen to the androidmanifest.xml))

Hello everybody.

When it’s the moment to compile my ionic 3 app with cordova i do:

“cordova build android”

And i get:

“BUILD FAILED” Because Cordova tries to compile with API 25.

The question is: How can I do to choose the API 22 with “cordova build android”?.

I read a lot about that and no luck. What files i could change to get what i want?.
If i change androidmanifest.xml does nothing, it is overwritted.
i see two androidmanifest,xml differents and two config.xml differents inside the structure of the app. Wich is the right file/s to change for choosen the targetAPI?.

Thank you.

Please edit your post, it is not very readable at the moment.
Use the </> button above the input field to format your code, command line output or error message (select the text first, then click the button or wrap it in ``` manually). Check the preview if it looks better. This will make sure your text is readable and if it recognizes the programming language it also automatically adds code syntax highlighting. Thanks.

Also post your ionic info output please.

in your AndroidManifest.xml you can specify it like
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="25" />

your targetSdkVersion=“22”

Also can set in config.xml

<platform name="android">

  <preference name="android-minSdkVersion" value="XX"/> 
  <preference name="android-targetSdkVersion" value="XX"/>

  <!--other line code -->


you have license agreements error for Android SDK Platform 25. check with your Android SDK Manager and make sure to install Android SDK Build-tool version 25.

Hope this will fix the issue. The solution worked for me.

I see two differents androidmanifest.xml and two config.xml files.

4! combinations.

I think (not sure), if i touch only the config.xml from www/appname/config.xml it works. But
it is not your config i think:

<?xml version='1.0' encoding='utf-8'?> MiAppAnimales A sample Apache Cordova application that responds to the deviceready event. Apache Cordova Team **** **** ****

I think the config.xml you say is in root/config,xml.

I do not know why are two configs.xml and wich is the right config.xml.

you can set this in your project’s root config.xml only. not sure why you having multiple config.xml, ionic 3 having only root config.xml

After changes in config.xml and compile, changes will reflect in Androidmanifest.xml auto, so if you do changes no need to make changes in Androidmanifest.xml

Yes, in the root i have the config.xml. But, if i do “cordova create AppName MyAppName”, the in the folder that cordova make, there is another config.xml.
Then, when you do “cordoba build android” there are the config.xml in the folder that cordova made and a config.xml in the root of ionic 3.

i will try only add to the root’s config.xml…

i think it is not working well. I do:

  1. Add ONLY to the root’s config.xml:

reference name=“android-minSdkVersion” value="16"
preference name=“android-maxSdkVersion” value="22"
preference name=“android-targetSdkVersion” value=“22”

  1. cordova create Appname MyAppName
  2. cordova platform add android

And i get:

"Using cordova-fetch for cordova-android@~6.2.2
Adding android project…
Creating Cordova project for the Android platform:
Path: platforms\android
Name: MiAppAnimales3
Activity: MainActivity
Android target: android-25
Subproject Path: CordovaLib
Android project created with cordova-android@6.2.3
Discovered plugin “cordova-plugin-whitelist” in config.xml. Adding it to the project
Installing “cordova-plugin-whitelist” for android

Adding cordova-plugin-whitelist to package.json
Saved plugin info for “cordova-plugin-whitelist” to config.xml
–save flag or autosave detected
Saving android@~6.2.3 into config.xml file …"

Again the target is API 25!!. But why if i put in config.xml target = 22?.

I don’t understand nothing.

Now, if a compile that, the APK again is target = 25.

I must clarify:

I have a config.xml in the ionic root folder, and another config.xml in the app folder than cordova creates.
Before a lot of hours in testing, only touching the config.xml from root in the app folder that cordova creates works.