Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Manifest Merger in Android Gradle Build

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?

like image 817
endian Avatar asked Dec 18 '12 16:12

endian


People also ask

Where is my merged manifest Android?

Even before you build your app, you can see a preview of what your merged manifest looks by opening your AndroidManifest. xml file in Android Studio, and then clicking the Merged Manifest tab at the bottom of the editor.

How do I fix manifest merger failed?

Some Useful Tricks to Solve Merge ErrorsAdd the overrideLibrary attribute to the <uses-sdk> tag. This may be useful when we try to import a library with a minSdkVersion value that is higher than the manifest file and an error occurs. The overrideLibrary tag lets the merger tool ignore this conflict.

How do I change AndroidManifest XML?

Open your Android project and go to <AppProjectFolder>/app/src/main/. Open the app manifest file AndroidManifest. xml and add the following lines to the file as child elements of the <manifest> element. Note: You must include the QUERY_ALL_PACKAGES permission if your app targets Android 11 (API Level 30) or higher.

Why is AndroidManifest XML used?

Every Android app project must include an AndroidManifest. xml file in the root of the project source set. The manifest file informs the Android build tools, the Android operating system, and Google Play with important information about your app.


2 Answers

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.

like image 92
Xavier Ducrohet Avatar answered Oct 19 '22 12:10

Xavier Ducrohet


This may help.

 android.applicationVariants.all{ variant ->
       variant.outputs.each { output ->
         output.processResources.manifestFile = file('AndroidManifest.xml')
         output.processManifest.enabled=false
       }
  }
like image 8
Uma sankar pradhan Avatar answered Oct 19 '22 13:10

Uma sankar pradhan