5

I am using a library which uses its own android:theme, and therefore I receive the following error while building: Error:(55, 9) Execution failed for task ':contacit:processDebugManifest'.

Manifest merger failed : Attribute application@theme value=(@style/Theme.MainTheme) from AndroidManifest.xml:55:9 is also present at com.github.florent37:materialviewpager:1.0.3.2:11:18 value=(@style/AppTheme) Suggestion: add 'tools:replace="android:theme"' to element at AndroidManifest.xml:49:5 to override

I've modified my app's AndroidManifest.xml as follows:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.main"
    android:versionCode="19"
    android:versionName="2.5" >
...
    <application
        android:name="com.example.application.MainApplication"
        tools:replace="android:theme"
        android:allowBackup="true"
        android:icon="@drawable/logo_icon"
        android:label="@string/app_name"
        android:theme="@style/Theme.MainTheme"
        >
...

However, even though I have used the tools:replace attribute, I am still getting the same error from the Manifest merger. Any ideas why?

Ohad
  • 1,450
  • 4
  • 18
  • 27
  • @Ohad Which manifest did you post in your question? The one of the app or the library? – Xaver Kapeller May 15 '15 at 09:34
  • @Xaver, this is AndroidManifest.xml of my app. (I do not want to modify the library's manifest) – Ohad May 15 '15 at 09:40
  • And why would you want to replace the theme of the app? does not really make sense. Add the tools:replace tag to the library. Or better yet, remove the `android:theme` tag from your library completely. No module should define a theme beside your app module. – Xaver Kapeller May 15 '15 at 09:54
  • @XaverKapeller , some libraries do it (for example, the very popular https://github.com/florent37/MaterialViewPager library). I do not want to change the library (I use gradle to import it) and it seems a reasonable solution would be as suggested here: http://stackoverflow.com/questions/24506800/android-studio-gradle-icon-error-manifest-merger . The problem is that this solution doesn't seem to work for the code I've attached above. – Ohad May 15 '15 at 10:04
  • Have you ever tried to remove the `android:theme` tag from the manifest of your app? – Xaver Kapeller May 15 '15 at 10:26
  • 1
    @XaverKapeller I want t keep it of course... I want to control my app's theme – Ohad May 15 '15 at 10:30
  • I have the same issue with icon attribute, everything's defined as per the doc example (http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger#TOC-Markers) but im still getting "Manifest merger failed". – Evgeni Roitburg May 17 '15 at 09:04
  • possible duplicate of [Manifest merger failed error](http://stackoverflow.com/questions/28095703/manifest-merger-failed-error) – CJBS Aug 04 '15 at 17:07
  • This question has more answers, you may find other answers [here](https://stackoverflow.com/questions/59663844/manifest-merger-failed-while-running/67280862#67280862) – Sweta Jain Apr 27 '21 at 14:30

1 Answers1

4

Remove tools:replace and add tools:node="replace" to application tag. It works for me.

Nam Vo
  • 129
  • 1
  • 3