dpogue opened a new issue #508: Inconsistent handling of min/target SDK values
URL: https://github.com/apache/cordova-android/issues/508
 
 
   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?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to