android build_error ai_generated true

Manifest merger failed : Attribute application@icon value=(@mipmap/ic_launcher) from AndroidManifest.xml:2:5-36 is also present at AndroidManifest.xml:8:5-41

ID: android/manifest-merger-failed-attribute-applicationicon

Also available as: JSON · Markdown · 中文
90%Fix Rate
86%Confidence
1Evidence
2024-04-12First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
AGP 7.0+ active
Android Studio 2022.1+ active

Root Cause

The same attribute (e.g., android:icon) is defined in multiple merged manifest files with conflicting values, causing a merge conflict.

generic

中文

同一属性(例如 android:icon)在多个合并的清单文件中定义且值冲突,导致合并冲突。

Official Documentation

https://developer.android.com/studio/build/manifest-merge

Workarounds

  1. 95% success Add tools:replace="android:icon" to the <application> tag in your main manifest to override library values
    Add tools:replace="android:icon" to the <application> tag in your main manifest to override library values
  2. 90% success Use tools:node="merge" with tools:replace to handle multiple conflicting attributes
    Use tools:node="merge" with tools:replace to handle multiple conflicting attributes
  3. 85% success Add tools:remove to exclude a conflicting attribute from a library manifest
    Add tools:remove to exclude a conflicting attribute from a library manifest

中文步骤

  1. 在主清单的 <application> 标签中添加 tools:replace="android:icon" 以覆盖库的值
  2. 使用 tools:node="merge" 配合 tools:replace 处理多个冲突属性
  3. 添加 tools:remove 以排除来自库清单的冲突属性

Dead Ends

Common approaches that don't work:

  1. 40% fail

    Removing may cause missing icon if it's required; better to use tools:replace to override.

  2. 50% fail

    If the manifests come from libraries, you may not have direct control over them.

  3. 60% fail

    tools:remove deletes the attribute entirely, which may not be desired.