Skip to content

Inconsistent handling of min/target SDK values #508

@dpogue

Description

@dpogue

cordova-android currently has a few different ways to specify a minimum SDK version and the target SDK version, and they are not equally exposed at various levels of tooling, and they can override each other in non-obvious ways (to non-native Android devs).

Traditionally, we've relied on the <uses-sdk> element in AndroidManifest.xml to specify the minimum, target, and (optionally) the maximum SDK versions. These can be customized via <preference> elements in an app's config.xml (android-minSdkVersion, android-targetSdkVersion, and android-maxSdkVersion respectively).

We also allow specifying these values via Gradle variables (cdvMinSdkVersion, and cdvCompileSdkVersion). If these variables are not specified, we default them.

According to Google's documentation:

If you specify API level requirements directly in your app's manifest file, the corresponding settings in the build files will override the settings in the manifest file. [...] [T]o avoid potential overwriting when the manifest is merged, you should remove these attributes from the <uses-sdk> element and define your API level settings in the Gradle build files instead.

In particular, I'm concerned about the possibility of someone specifying a minimum SDK version in config.xml, and that getting overridden by the default minimum SDK version of 19 via gradle.

Google seems to recommend using Gradle properties, which was also brought up in my PR about updating the Gradle build files.
It seems to me like the correct thing to do is to take the SDK versions specified in config.xml and transform them into both <uses-sdk> attributes (as is done currently), but also into gradle properties. We don't currently have a good way to do that, but @erisu's PR #465 provides a gradle.properties file that we could inject cdvMinSdkVersion and cdvCompileSdkVersion into.

Thoughts/Concerns/Feedback?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions