Home » Android » Android Manifest vs Gradle Script

Android Manifest vs Gradle Script

Posted by: admin June 15, 2020 Leave a comment


I set minSdkVersion to be 8 in Gradle build script and minSdkVersion to be 4 in Android module manifest.

Which one is taken? Why aren’t these 2 synchronized?

How to&Answers:

When there was no gradle support in Android, the manifest ruled it all. Now, if you added gradle support to your project, old manifest tags are simply ignored, as gradle builds your app and decides which is correct minimum version.

The main reason of this has to be identified in this fact:

These build values override the existing values in the manifest file.
This is useful if you want to generate multiple APKs for your modules
where each of the apk files has a different application name, minimum
SDK version, or target SDK version. When multiple manifests are
present, manifest settings are merged in priority of buildType and
productFlavor, /main manifest, and the library manifests

In other words, gradle allows Build variants and lets you specify min and target SDKs for each.