清单合并失败错误

Jam*_*ing 56 java android gradle android-manifest android-studio

我正在将当前项目的大型应用程序移动到Android Studio和Gradle中.我目前陷入以下问题:

Error:(87, 9) Execution failed for task ':App:processDebugManifest'.
> Manifest merger failed : Attribute application@label value=(@string/app_label) from AndroidManifest.xml:87:9
    is also present at ANDROID_APPLICATION:Library:unspecified:9:18 value=(@string/app_name)
    Suggestion: add 'tools:replace="android:label"' to <application> element at AndroidManifest.xml:82:5 to override
Run Code Online (Sandbox Code Playgroud)

我尝试将以下属性添加到主AndroidManifest.xml文件中:

tools:replace="android:label, *App Name*"
tools:replace="android:label, @string/app_label"
tools:replace="android:label"
Run Code Online (Sandbox Code Playgroud)

这些属性定义都不起作用.我究竟做错了什么?

Kay*_*n N 145

尝试一下:

将此添加到 <manifest/>

xmlns:tools="http://schemas.android.com/tools"
Run Code Online (Sandbox Code Playgroud)

将此添加到 <application/>

tools:node="replace"
Run Code Online (Sandbox Code Playgroud)

基于,它应该覆盖所有元素."用带注释的声明替换低优先级声明."

  • @kayvan 在使用(tools:node =“replace”)之后我在 firebase 设置中崩溃了 (2认同)
  • 为了热爱所有神圣的事物,如果您使用 Firebase,请勿使用此功能。我浪费了 2 天的时间试图理解为什么我的 Firebase 设置不起作用,最后追溯到这里。 (2认同)

CJB*_*JBS 33

背景

合并清单文件时,与label属性存在冲突.

通常,有三种类型的清单文件需要合并到一个生成的应用程序清单中,此处按优先级顺序排列:

  1. 产品风格和构建类型特定的清单文件.
  2. 应用程序的主要清单文件.
  3. 库清单文件.

决议

可以通过以下两种方式解决冲突: -

删除冲突的标签

从库(或更低级别)清单文件中删除冲突属性.

在这种情况下,定义ANDROID_APPLICATION:Library:unspecified:9:18 value=(@string/app_name)@string/app_name值与主应用程序中的值不同.因此,如果不需要,则删除它 - 只需android:label="@string/app_name"从库文件的AndroidManifest.xml文件中删除它.

添加属性以允许自动解决冲突

几个特殊属性标记(在工具命名空间中)可用于表达如何解决冲突的特定决策.

在这种情况下,明确地引起主应用程序的android:label重写任何其他(如库文件)应用程序标签中,添加xmlns:tools="http://schemas.android.com/tools"定义为<manifest>节点,tools:replace="label"<application>节点.

这是一个例子 - 在主应用程序的AndroidManifest.xml文件中使用它:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.mycompany.myapp"
    xmlns:tools="http://schemas.android.com/tools">

    <application
        android:label="@string/app_name"
        tools:replace="label"/>
</manifest>
Run Code Online (Sandbox Code Playgroud)

这种方法也适用于任何其他冲突的属性; 例如,如果icon属性也存在冲突,则可以将其更改为tools:replace="label, icon".


dm7*_*m78 6

如果你像我一样幸运的话,你可以通过一个 hacky work-around 手动修复这个问题。

AAR 文件只是带有 .aar 扩展名的 .zip 文件。就我而言,我解压缩了 .aar,android:label从库的AndroidManifest.xml.

仅供参考,这似乎是 android gradle 插件中的一个已知错误