问题描述:

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

Which one taken? Why these 2 are not synchronized each other?

网友答案:

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.

相关阅读:
Top