Disable Manifest Merger in Android Gradle Build

endian picture endian · Dec 18, 2012 · Viewed 11.8k times · Source

I am using the new gradle android buildsystem.

The project consists of two android library projects and one main project.

Using the ant build, the manifest merger must be enable in project.properties. But when using the gradle build system the manifest merger is enabled by default. How can i disable the manifest merger?

Answer

Xavier Ducrohet picture Xavier Ducrohet · Dec 19, 2012

Edit: this is actually possible though indirectly, starting with 0.3

What you need to do is disable the processManifest task so that it doesn't run and tell the processResources where the manifest to use is:

android.applicationVariants.all { variant ->
    variant.processResources.manifestFile = file('src/main/AndroidManifest.xml')
    variant.processManifest.enabled=false
}

Note that if you are customizing the app package name through the DSL, you should keep the default manifest untouched in the default location to provide a consistent package name for the R classes, and then have your manually merged manifests somewhere else and point each variant processResources task to them.