5
votes

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?

1
@Ohad Which manifest did you post in your question? The one of the app or the library? - Xaver Kapeller
@Xaver, this is AndroidManifest.xml of my app. (I do not want to modify the library's manifest) - Ohad
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
@XaverKapeller , some libraries do it (for example, the very popular 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: stackoverflow.com/questions/24506800/… . The problem is that this solution doesn't seem to work for the code I've attached above. - Ohad
@XaverKapeller I want t keep it of course... I want to control my app's theme - Ohad

1 Answers

4
votes

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