Patrick Brennan
Patrick Brennan

Reputation: 2738

Android Studio Build Error: manifestMergerXXXX?

I am running Android Studio 2.0 Beta 3. I have a project which depends on an external library. When I build using Android Studio, I am getting the following error message:

($my_project_path)/build/intermediates/manifest/tmp/manifestMerger354333932548019277.xml:17:9-36 Error:
Attribute application@allowBackup value=(false) from [debug] AndroidManifest.xml:17:9-36
is also present at [($library)] AndroidManifest.xml:12:9-35 value=(true)
Suggestion: add 'tools:replace="android:allowBackup"' to <application> element at manifestMerger354333932548019277.xml:7:5-9:19 to override
Error:Execution failed for task ':$(project):processDebugAndroidTestManifest'.
> java.lang.RuntimeException: Manifest merger failed : Attribute application@allowBackup value=(false) from [debug] AndroidManifest.xml:17:9-36
is also present at [($library)] AndroidManifest.xml:12:9-35 value=(true)
Suggestion: add 'tools:replace="android:allowBackup"' to <application> element at manifestMerger354333932548019277.xml:7:5-9:19 to override

This is very weird. Android Studio is suggesting that I edit the product of an intermediate build step in order to get my compile to complete? Also, when I look at the source AndroidManifest.xml's in question, the upper-level one already defines the "tools-replace" attribute as "android:allowBackup". In short, I have no idea why I should be getting this message. Also, my build works perfectly well from the command line. Any suggestions?

EDIT based on comments: Some commenters have noted that I need to follow the very clear directions in the error message, only these commenters are missing that the error message is directing me to edit an intermediate build product.

To be very clear: An intermediate build product is not something that a build system should EVER, EVER, direct a user to modify. It is by definition something for the use of the build system alone. Its only additional use is for preserving state so that the user can troubleshoot bad builds. The fact that Android Studio is telling me to modify this file is evidence that something is seriously broken, either in Android Studio, or more likely, in my configuration and/or build scripts. But, what?

For clarification, here is the <application> element from the project that includes the library:

<application
    android:label="@string/app_name"
    android:allowBackup="false"
    tools:replace="android:allowBackup">
    <...>
</application>

So as you can see, I am declaring the very element that Android Studio is complaining about, exactly the way I am being requested. Except NOT! Because Android Studio is asking me to modify the merged AndroidManifest.xml - clearly something I should not be doing, because it is a build product. This project is building on all my colleagues' machines, because they didn't update to the latest Android Studio. It's on me now, and frankly I think the best thing for me to do is to uninstall Android Studio and start over.

Upvotes: 3

Views: 3180

Answers (3)

Patrick Brennan
Patrick Brennan

Reputation: 2738

I reverted to Android Studio 1.5.1 and I am able to build and run without any issues.

Upvotes: 0

JBirdVegas
JBirdVegas

Reputation: 11413

The error message tells you how to resolve the issue

Suggestion: add 'tools:replace="android:allowBackup"' to <application> element

Basically you declared the allowBackup Manifest attribute twice. Once in the AndroidManifest.xml file and again in the library (probably via gradle).

FYI in this case the gradle declaration will win.

Upvotes: 6

Trash Can
Trash Can

Reputation: 6824

What it is saying is that, the library you depend on also has a similarly named attribute which prevents android from merging that manifest with your manifest. When Android builds your apk, it will merge Manifest files from different projects and it will try to merge them all to produce the artifact for a build variant. Android is basically a Gradle multi-project build. So you have to resolve the conflict yourself.

Upvotes: 0

Related Questions