Android - best practices for variables in Gradle build script

It's just interesting what is best used to use variables in Gradle build scripts. More specifically, I installed minSdkVersion and targetSdkVersion in my buildscript, and Android Studio presents the following message when viewing the application manifest.

This minSdkVersion value (14) is not used; it is always overridden by the value specified in the Gradle build script(14) 

This is a snippet from my build script:

 android { compileSdkVersion 19 buildToolsVersion '19.0.0' defaultConfig { minSdkVersion 14 targetSdkVersion 19 } buildTypes { release { runProguard true proguardFile getDefaultProguardFile('proguard-android-optimize.txt') } } productFlavors { defaultFlavor { proguardFile 'proguard-rules.txt' } } } 

Should I keep the declaration in the manifest? or should I remove any variables that I set in the build script from the application manifest?

Thank you very much.

+6
source share
1 answer

I had the same question. You may have found the answer at this point, but some searches have finally led me to this website .

It seems that all the basics of Gradle very well explained. To answer your specific question, find Manifest Entries in the Basic Build Customization section. Nearby, as far as I can tell, it works great to define minSdkVersion in a build script or in AndroidManifest.

As the website explains, part of the purpose behind this design was to make it more dynamic and more easily allow the creation of multiple APKs using essentially the same code.

I probably didn’t explain it best, but this website does a pretty good job.

+3
source

All Articles