Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community. Show By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails. I am an amateur and relatively new to the world of Java and Android as I have just started learning. However, I faced an error when I was trying to experiment with Intent. It has been mentioned below:- Error:Execution failed for task ':app:processDebugManifest'. > Manifest merger failed with multiple errors, see logs I tried and got some solutions along with trying to implement them, but unfortunately it did not work. I have shared my build.gradle below:- An Android Studio project generally contains more than one Android Manifest.xml file. They are provided by the main sources set, imported libraries, and build variants. However, we know that the Android App Bundle file can contain only one AndroidManifest.xml file. So, the Gradle build merges all these manifest files into a single file. This process is carried out while building the application. What is Manifest Merger?The manifest merger tool plays an important role in combining all XML elements from each file. It follows merge heuristics and obeys all the merge preferences with special XML attributes defined by the user. The job of the merger tool is to logically match all the XML elements in one manifest with their respective elements in other manifests. What is Merge Conflict?A merge conflict occurs while merging whenever the value of any attribute is different in the two Manifest files. However, if an element from the lower-priority manifest does not match any elements in the high-priority manifest, then it is added to the merged manifest. And, if there is a matching element, then the merger tool combines all attributes from each into the same element. Note: Use the Merged Manifest view to preview the results of your merged manifest and find conflict errors. How to Resolve Merge Conflict?Sometimes, it is possible that the higher-priority manifest is dependent on the default value of an attribute, but this value is not declared in the file. As all the unique elements are combined into the same element, a Merge Conflict may occur. Therefore, it is advisable not to be dependent on the default attribute values. For an instance, if the higher priority manifest uses “standard” as the default value for the android:launchMode attribute, without declaring it in the file and the lower-priority manifest assigns a different value to the same attribute, that value overrides the default value. Hence, it is applied to the merged manifest file. Therefore, the value of each attribute should be explicitly defined as per requirement. Note: Default values for each attribute are documented in the Manifest reference. Merge Rule MarkersThese are XML attributes that can be used to express the user’s preference about how to solve merge conflicts or remove unnecessary elements and attributes. A marker can be applied to either an entire element or to a specific attribute. When merging two manifest files, the merger tool looks for these markers in the higher-priority manifest file. All markers belong to the Android tools namespace. Hence, they must be declared in the <manifest> element as shown: XMLNode MarkersTo apply a merge rule to an entire XML element (to all attributes in a given manifest element and to all its child tags), use the following attributes:
This creates a manifest merge error. The two manifest elements cannot differ at all in strict mode. So you must apply other merge rule markers to resolve these differences. Note: For app modules, tools merge markers are removed after the merge; however, for library modules, tools merge markers are not removed after the merge and may affect merges in a downstream module. Attribute MarkersInstead, apply a merge rule only to specific attributes in a manifest tag, use the following attributes. Each attribute accepts one or more attribute names (including the attribute namespace), separated by commas.
Marker SelectorIf you want to apply the merge rule markers to only a specific imported library, add the tools:selector attribute with the library package name. For example, with the following manifest, the remove merge rule is applied only when the lower-priority manifest file is from the com.example.lib1 library. If the lower-priority manifest is from any other source, the remove merge rule is ignored. If it is used with one of the attribute markers, then it applies to all attributes specified in the marker. |