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>`](https://developer.android.com/guide/topics/manifest/uses-sdk-element)
 element in AndroidManifest.xml to specify the minimum, target, and 
(optionally) the maximum SDK versions. These can be customized via 
[`<preference>`](https://cordova.apache.org/docs/en/latest/config_ref/index.html#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](https://cordova.apache.org/docs/en/latest/guide/platforms/android/index.html#configuring-gradle)
 (`cdvMinSdkVersion`, and `cdvCompileSdkVersion`). If these variables are not 
specified, we [default 
them](https://github.com/apache/cordova-android/blob/master/bin/templates/project/app/build.gradle#L101-L121).

According to [Google's 
documentation](https://developer.android.com/studio/publish/versioning#minsdkversion):
> 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](https://github.com/apache/cordova-android/pull/507#issuecomment-424865560) 
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 
https://github.com/apache/cordova-android/pull/465 provides a gradle.properties 
file that we could inject `cdvMinSdkVersion` and `cdvCompileSdkVersion` into.

Thoughts/Concerns/Feedback?

[ Full content available at: 
https://github.com/apache/cordova-android/issues/508 ]
This message was relayed via gitbox.apache.org for [email protected]

Reply via email to