Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manifest merger failed error

I am in the process of moving my current projects huge application into Android Studio and Gradle. I am currently stuck on the following issue:

Error:(87, 9) Execution failed for task ':App:processDebugManifest'. > Manifest merger failed : Attribute application@label value=(@string/app_label) from AndroidManifest.xml:87:9     is also present at ANDROID_APPLICATION:Library:unspecified:9:18 value=(@string/app_name)     Suggestion: add 'tools:replace="android:label"' to <application> element at AndroidManifest.xml:82:5 to override 

I have tried adding the following attributes to the main AndroidManifest.xml file:

tools:replace="android:label, *App Name*" tools:replace="android:label, @string/app_label" tools:replace="android:label" 

None of these attribute definitions works. What am I doing wrong?

like image 926
James King Avatar asked Jan 22 '15 18:01

James King


People also ask

How do I fix error manifest merger failed?

The initial process would be to open the manifest application known as the AndroidManifest. xml and then click on the Merged Manifest tab below your edit pane. Following which, Click on the merged manifest option. An Error would be visible at the right column and then one must try to solve the error.

What is manifest merger?

The manifest merger tool combines all XML elements from each file by following some merge heuristics and by obeying merge preferences that you have defined with special XML attributes. This page describes how manifest merging works and how you can apply merge preferences to resolve merge conflicts.

What is manifest file in APK?

The manifest file describes essential information about your app to the Android build tools, the Android operating system, and Google Play.


2 Answers

Give this a try:

Add this to <manifest/>

xmlns:tools="http://schemas.android.com/tools" 

Add this to <application/>

tools:node="replace" 

Based on this, it should override all the elements. "Replace the lower priority declaration with the annotated one."

like image 199
Kayvan N Avatar answered Sep 28 '22 09:09

Kayvan N


Background

When the manifest files are being merged, there is a conflict with the label attribute.

In general, there are three types of manifest files that need to be merged into a single resulting app manifest, here in priority order :

  1. Product flavors and build types specific manifest files.
  2. Main manifest file for the application.
  3. Library manifest files.

Resolutions

The conflict can be resolved in one of two ways:-

Remove the conflicting label

Remove the conflicting attribute from the library (or lower-level) manifest file.

In this case, the ANDROID_APPLICATION:Library:unspecified:9:18 value=(@string/app_name) has a @string/app_name value defined that's different from that in the main application. So if it's not required, then remove it -- simply remove the android:label="@string/app_name" from the library file's AndroidManifest.xml file.

Add an attribute to allow an automatic resolution to the conflict

There are several special attribute markers (in the tools namespace) that may be used to express a specific decision for how to resolve conflicts.

In this case, to explicitly cause the main app's android:label to override any other (e.g. library file) application labels, add the xmlns:tools="http://schemas.android.com/tools" definition to the <manifest> node, and tools:replace="label" to the <application> node.

Here is an example - use this in the main application's AndroidManifest.xml file:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"     package="com.mycompany.myapp"     xmlns:tools="http://schemas.android.com/tools">      <application         android:label="@string/app_name"         tools:replace="label"/> </manifest> 

This approach would also work with any other conflicting attributes; for example if the icon attribute was also in conflict, it could be changed to tools:replace="label, icon".

like image 24
CJBS Avatar answered Sep 28 '22 09:09

CJBS