42

I want add android platform on cordova using specific version: android-10. I use 'gulp' with 'gulp-shell' to create cordova env, so it must be repeatable in command line for CI and CD.

Today when I run:

$ cordova platforms add android

It create in platforms/android/AndroidManifest.xml file :

android:minSdkVersion="10" android:targetSdkVersion="19"

I want android:minSdkVersion="14" android:targetSdkVersion="19"

AtanuCSE
  • 8,832
  • 14
  • 74
  • 112
chucre
  • 436
  • 1
  • 4
  • 6
  • possible duplicate of [How can I specify the minimum SDK in phonegap? It is ignoring android-minsdkversion in config.xml](http://stackoverflow.com/questions/27135185/how-can-i-specify-the-minimum-sdk-in-phonegap-it-is-ignoring-android-minsdkvers) – mix3d Jun 24 '15 at 16:12
  • I think your question title is misleading, because it seems to ask about a specific version of the android platform, not a min-sdk – mix3d Jun 24 '15 at 16:13
  • You can also add directly from the repo: `cordova platform add https://github.com/apache/cordova-android.git#7.1.0` – Alex Steinberg Dec 03 '18 at 13:11

5 Answers5

68

Try to check here what is the list of Android Platforms => Cordova Android Platforms

and try to use:

cordova platform add android@x.x.x

replacing x.x.x with the version that you need

A list of released version can be found on github.

Peter T.
  • 2,927
  • 5
  • 33
  • 40
MeV
  • 3,761
  • 11
  • 45
  • 78
  • 2
    This is good for the right version of the android plugin, but it doesnt affect the min version of the default manifest once the app is added. – mix3d Jun 24 '15 at 15:54
  • for example `android@4.1.1` – Mohammed Sufian Apr 12 '17 at 14:02
  • For Android 6 we need to use `android@6.3.0`. I figured this out by trial and error. Is there a list where this is documented? – krv Jan 18 '18 at 14:27
15

In your cordova project's config.xml, add an android platform section:

<platform name="android">
    <preference name="android-minSdkVersion" value="14" />
</platform>

This way each time you build, it will get added to the android manifest, instead of getting overwritten each time you rebuild.

If you want to target a newer platform than 19, then you can use a second preference:

<preference name="android-targetSdkVersion" value="22" />

Cheers!

mix3d
  • 4,122
  • 2
  • 25
  • 47
3

A trick if you don't known which x.x.x release is available, request only the master version. E.g. :

cordova add platform android@4

, will install the next available 4.x.x release. today 4.1.1.

Enjoy

Bruno

bruno777
  • 1,896
  • 2
  • 11
  • 5
0

The command to add a specific version of android platform via cordova is:

 cordova platform add android@VERSION

eg.

cordova platform add android@8
EigenFool
  • 443
  • 1
  • 6
  • 14
-6

Change the AndroidManifest.xml maually. Open that file in any editor. Then set your choices.

android:minSdkVersion="14" android:targetSdkVersion="19"

And build the project

$ cordova build android

Goal

AtanuCSE
  • 8,832
  • 14
  • 74
  • 112
  • I want know if cordova command has any argument to do that, or any other command exists. – chucre Jul 14 '14 at 01:39
  • 2
    This will also get overwritten if the platform is ever removed, or even when building through the CLI – mix3d Jun 24 '15 at 16:02
  • 2
    Editing the platform folder manually is a non-permanent nor portable solution, since the platform folder can be removed or added at any time; the Cordova project should handle this correctly, so the project can be shared more easily. – mix3d Jun 24 '15 at 16:09
  • platform folder might be removed. – Diego Marafetti Aug 19 '16 at 20:28