Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect default min SDK version ternary in build.gradle #489

Closed
tombell opened this issue Sep 4, 2018 · 4 comments · Fixed by #495
Closed

Incorrect default min SDK version ternary in build.gradle #489

tombell opened this issue Sep 4, 2018 · 4 comments · Fixed by #495
Labels

Comments

@tombell
Copy link

tombell commented Sep 4, 2018

I've been trying to work out why the min SDK was always being set to 19 even when I updated it to 23 every where possible.

I believe I've found an issue here https://github.com/apache/cordova-android/blob/master/bin/templates/project/app/build.gradle#L120 where it's setting the cdvMinSdkVersion to null when it's already null, else if it's not null it's setting it to the default min SDK version, meaning if you ever set a min SDK it will always change it to the default.

I believe the correct line should read:

ext.cdvMinSdkVersion = cdvMinSdkVersion == null ? defaultMinSdkVersion : cdvMinSdkVersion
@janpio janpio added the bug label Sep 4, 2018
@tombell
Copy link
Author

tombell commented Sep 4, 2018

I also noticed that gradle extensions get injected before these versions are determined, meaning any plugin relying on these sees them as null.

// ...

// PLUGIN GRADLE EXTENSIONS START
apply from: "../cordova-plugin-browsertab/mobile-BrowserTab.gradle"
// PLUGIN GRADLE EXTENSIONS END

def hasBuildExtras = file('build-extras.gradle').exists()
if (hasBuildExtras) {
    apply from: 'build-extras.gradle'
}

// Set property defaults after extension .gradle files.
if (ext.cdvCompileSdkVersion == null) {
    ext.cdvCompileSdkVersion = privateHelpers.getProjectTarget()
    //ext.cdvCompileSdkVersion = project.ext.defaultCompileSdkVersion
}
if (ext.cdvBuildToolsVersion == null) {
    ext.cdvBuildToolsVersion = privateHelpers.findLatestInstalledBuildTools()
    //ext.cdvBuildToolsVersion = project.ext.defaultBuildToolsVersion
}
if (ext.cdvDebugSigningPropertiesFile == null && file('../debug-signing.properties').exists()) {
    ext.cdvDebugSigningPropertiesFile = '../debug-signing.properties'
}
if (ext.cdvReleaseSigningPropertiesFile == null && file('../release-signing.properties').exists()) {
    ext.cdvReleaseSigningPropertiesFile = '../release-signing.properties'
}

// Cast to appropriate types.
ext.cdvBuildMultipleApks = cdvBuildMultipleApks == null ? false : cdvBuildMultipleApks.toBoolean();
ext.cdvVersionCodeForceAbiDigit = cdvVersionCodeForceAbiDigit == null ? false : cdvVersionCodeForceAbiDigit.toBoolean();
ext.cdvMinSdkVersion = cdvMinSdkVersion == null ? defaultMinSdkVersion : cdvMinSdkVersion
ext.cdvVersionCode = cdvVersionCode == null ? null : Integer.parseInt('' + cdvVersionCode)

//...

@DavidWiesner
Copy link
Contributor

This is still an issue in 7.1.2. As workaround you can specify overwrite the defaultMinSdkVersion in a build-extras.gradle file in platform/android/app/

ext.defaultMinSdkVersion = 23

@dpogue
Copy link
Member

dpogue commented Nov 14, 2018

This was not cherry-picked to the bugfix branch for 7.1.x, it will be included in the next major version.

@DavidWiesner
Copy link
Contributor

@dpogue I did not understand the motivation for not including this in the bugfix branch it is documentented to work like that. So it is clearly a bug. I also add a pull request #551 for the missing type cast

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants