cordova build setting cdvMinSdkVersion
Asked Answered
C

2

5

I am attempting to build an Android APK using the following command:

cordova build android --release -- --gradleArg=-PcdvMinSdkVersion=19

Yet when I verify which minSdkVersion the built APK targets, I am informed it's version 15 (0xf):

aapt list -a android-release.apk | grep SdkVersion

Why is the first command not working?

I am NOT using Crosswalk (looking at build.gradle, this should not matter anyway).

Chloromycetin answered 25/8, 2016 at 10:46 Comment(0)
C
7

I have found the answer - I am using the plugin phonegap-plugin-barcodescanner which explicitly sets the minSdkVersion in its own build.gradle file:

ext.cdvMinSdkVersion=15

Is the very first line.

Chloromycetin answered 25/8, 2016 at 11:18 Comment(2)
They have updated the phonegap-plugin-barcodescanner library now which includes a fix for this :). Prior to this fix, I was commenting this line out (which isn't great, but it worked).Chloromycetin
I honestly don't think it's a problem with the plugin. Even if you set minSdkVersion on command line and also in config.xml (which should update it in the AndroidManifest), and even though the build script totally HAS this number floating around... it'll ignore it. The plugin's build.gradle doesn't directly wipe it out, the main build.gradle fails to take 2 minimums and choose the larger.Hypogeous
T
2

In my case the same problem was fixed by adding the following setting in the config.xml file:

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

You may use whatever android SDK version as a minimum as you wish.

Terle answered 1/10, 2020 at 17:20 Comment(1)
This Cordova setting does not work with the latest android version, there are some breaking changes, the manual fix is through a setting in build.gradle file as @Chloromycetin mentionedSlavophile

© 2022 - 2024 — McMap. All rights reserved.