【问题标题】:Manifest merger failed : Attribute application@theme清单合并失败:属性 application@theme
【发布时间】:2016-12-23 13:52:02
【问题描述】:

我正在尝试使用this ProgressWheel librery,但是在运行项目后我遇到了这个错误。

错误:任务 ':app:processDebugManifest' 执行失败。

清单合并失败:AndroidManifest.xml:11:9-40 中的属性 application@theme value=(@style/AppTheme) 也是 出现在 [com.github.Todd-Davies:ProgressWheel:1.2] AndroidManifest.xml:13:9-56 值=(@android:style/Theme.NoTitleBar)。 建议:添加 'tools:replace="android:theme"' 到 AndroidManifest.xml:5:5-23:19 中的元素进行覆盖。

这是我的清单

<?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>

还有我的 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>

知道如何解决吗?

【问题讨论】:

    标签: android android-manifest android-styles


    【解决方案1】:

    知道如何解决吗?

    按照错误消息中提供给您的说明进行操作:

    建议:将 'tools:replace="android:theme"' 添加到 AndroidManifest.xml:5:5-23:19 的元素以覆盖。

    换句话说,将tools:replace="android:theme" 添加到您的&lt;application&gt; 元素中。

    或者,切换到其他库。

    【讨论】:

    • 是的,我要切换到不同的库,我现在面临另一个问题。
    • 没有其他选择吗?
    • @SlickSlime:为什么在清单中添加 tools:replace="android:theme" 会出现问题?
    • @CommonsWare 似乎应用程序级别的 tools:replace="android:theme" 改变了库中主题 UI 元素的外观。这是预期的吗?如果是这样,那就有问题了。有什么办法解决这个问题吗?库中的清单属性在清单合并期间没有获得自己的命名空间似乎很奇怪......
    • @CCJ:“这是预期的吗?” - 是的。我的意思是,tools:replace 的意义在于替换来自图书馆的东西。 “有什么办法解决这个问题吗?” -- 不要使用tools:replace 并使用图书馆的主题。或者,不要使用库。或者,与库开发人员交谈,看看他们有什么建议。在&lt;application&gt; 元素在库中 上具有android:theme 属性可能在特定场景中有效(例如,驱动整个UI 的框架),但总的来说它似乎应该是代码味道。
    【解决方案2】:

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

    经过大量搜索,我发现这个解决方案有效,实际上,他和另一个告诉添加的方法一样

    将这两行android:theme="@style/AppTheme"tools:replace="android:theme"添加到application标签

    另外,将此行 xmlns:tools="http://schemas.android.com/tools" 也添加到根清单标记

    这是完整的代码

    
    <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>
    
    

    【讨论】:

      猜你喜欢
      • 2019-08-08
      • 1970-01-01
      • 2019-11-19
      • 1970-01-01
      • 1970-01-01
      • 2019-11-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多