cordova-android: cdvMinSdkVersion seems to not work in 7.1.4

I specified this <preference name="android-minSdkVersion" value="23" /> into config.xml, but it seems not work in 7.1.4.

I think these PRs might cause this problem.

https://github.com/apache/cordova-android/blob/a68f9fd752a25bb680da96414a3b956357c2dfcb/bin/templates/project/app/build.gradle#L125

I quickly fix this line to ext.cdvMinSdkVersion = cdvMinSdkVersion == null ? null : Integer.parseInt('' + defaultMinSdkVersion). It seems to work well.

I think actual cdvMinSdkVersion is set on this line.

https://github.com/apache/cordova-android/blob/a68f9fd752a25bb680da96414a3b956357c2dfcb/bin/templates/project/app/build.gradle#L171

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 10
  • Comments: 18 (9 by maintainers)

Most upvoted comments

FYI: The workaround is to specify gradleArg when you build.

cordova build android -- --gradleArg=-PcdvMinSdkVersion=23

This will override minSdkVersion. I confirmed it works on 7.1.4.

You can confirm whether it works well using aapt command.

aapt l -a path/to/apk/android-release.apk | grep 'minSdkVersion'

I solved changing lines in file: platforms/android/gradle.properties

org.gradle.daemon=true
org.gradle.jvmargs=-Xmx2048m
android.useDeprecatedNdk=true
cdvMinSdkVersion=21

to

org.gradle.daemon=true
org.gradle.jvmargs=-Xmx2048m
android.useDeprecatedNdk=true
cdvMinSdkVersion=19

I’m seeing something like this after upgrading to v8 from v7.x, not sure if that’s expected.

Symptoms:

It seems like a minimum SDK < 19 is no longer supported so I changed my preference in config.xml:

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

When I build (cordova build android) I get the following warning (which eventually causes the build to fail):

[Gradle Properties] Detected Gradle property "cdvMinSdkVersion" with the value of "16", Cordova's recommended value is "19"

When I search through the AndroidManifest.xml files under platforms/android everything is saying 19, so the merge has worked but it seems like there is a gradle property sticking around somewhere. (FYI I know almost nothing about the internals of gradle or the Android build process 😕 .)

I’m going to try @falcon8823 's workaround for now.

Update from my notes:

Seems like at some point the minSdkVersion parameter got saved to platforms/android/gradle.properties and then always overrides the other config.

Just delete the line and rebuild.

@eddskt Yes, that worked for me

@dmastag Yes, that worked for me