Manifest merger failed : Attribute application@theme
Asked Answered
E

2

12

I am trying to use this ProgressWheel librery, but I am facing this error after run the proyect.

Error:Execution failed for task ':app:processDebugManifest'.

Manifest merger failed : Attribute application@theme value=(@style/AppTheme) from AndroidManifest.xml:11:9-40 is also present at [com.github.Todd-Davies:ProgressWheel:1.2] AndroidManifest.xml:13:9-56 value=(@android:style/Theme.NoTitleBar). Suggestion: add 'tools:replace="android:theme"' to element at AndroidManifest.xml:5:5-23:19 to override.

This is my manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.anda.soft.apppresentation">

    <application
        android:name=".di.App"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".ui.activities.MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <meta-data
            android:name="io.fabric.ApiKey"
            android:value="xxxxxxxxxxxxxxx"
            />
    </application>
    <uses-permission android:name="android.permission.INTERNET" />
</manifest>

and my style.xml

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

</resources>

Any idea about how to solve it?

Entrench answered 23/12, 2016 at 13:52 Comment(0)
I
26

Any idea about how to solve it?

Follow the instructions that were given to you in the error message:

Suggestion: add 'tools:replace="android:theme"' to element at AndroidManifest.xml:5:5-23:19 to override.

In other words, add tools:replace="android:theme" to your <application> element.

Or, switch to a different library.

Inspectorate answered 23/12, 2016 at 13:54 Comment(5)
Yes I am going to switch to a different library , I am facing another issue now .Entrench
Isn't there any other alternative?Smalley
@SlickSlime: Why is adding tools:replace="android:theme" in the manifest a problem?Inspectorate
@Inspectorate it seems that tools:replace="android:theme" at the application level changes the look of themed UI elements in libraries. Is that expected? If so, that's a problem. Any way to work around that? It seems strange that manifest attributes in libraries don't get their own namespace during manifest merging...Staunch
@CCJ: "Is that expected?" -- yes. I mean, the point of tools:replace is to replace something coming from a library. "Any way to work around that?" -- don't use tools:replace and live with the theme from the library. Or, don't use the library. Or, talk to the library developers and see what recommendations they have. Having an android:theme attribute on an <application> element in a library might be valid in specific scenarios (e.g., a framework that drives the whole UI), but on the whole it seems like it should be a code smell.Inspectorate
R
9

https://github.com/sawankumarbundelkhandi/edge_detection/issues/12#issuecomment-669854455

After a lot of searching, I found this solution working, actually, he did the same as the other told to add

Add these two lines android:theme="@style/AppTheme" and tools:replace="android:theme" to the application tag

Also, add this line xmlns:tools="http://schemas.android.com/tools" to the root manifest tag too

Here is the full code


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.doitcare.app"
    xmlns:tools="http://schemas.android.com/tools">
    <application
        tools:replace="android:theme"
        android:theme="@style/AppTheme"
        ...>
        <activity
            ...
        </activity>
    </application>
</manifest>

Rafaelle answered 19/3, 2021 at 14:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.