【问题标题】:How to resolve Manifest merger Failed error如何解决清单合并失败错误
【发布时间】:2018-09-20 01:35:34
【问题描述】:

当我将优雅的数字按钮库添加到我的 gradle 文件时,我收到清单合并失败错误。

清单合并失败:属性 application@icon 来自 AndroidManifest.xml:20:9-41 的 value=(@mipmap/app_logoo) 也是 出现在 [com.cepheuen.elegant-number-button:lib:1.0.3] AndroidManifest.xml:13:9-43 值=(@mipmap/ic_launcher)。建议: 将 'tools:replace="android:icon"' 添加到元素 AndroidManifest.xml:18:5-56:19 覆盖。

我已尝试添加此库的所有版本,但没有一个有效

【问题讨论】:

    标签: android-studio android-gradle-plugin android-manifest


    【解决方案1】:

    正如错误建议所说,您需要将tools:replace="android:icon" 添加到您的AndroidManifest.xmltools:replace 表示您想用AndroidManifest.xml 中的当前属性值替换属性值。

    你可以这样做:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        package="com.example.yourapp">
    
      <application
          android:name=".YourApp"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          tools:replace="android:icon">
    
          <!-- code omitted here -->
    
       </application>
    
    </manifest>
    

    【讨论】:

    • 但是我也从清单文件中删除了我的标志,这也有效......我不知道为什么我的标志出现错误
    • 这个错误是因为android manifest合并工具会合并你所有项目中的所有AndroidManifest.xml,并且发现已经有相同的属性,所以它会抱怨它。因此,您需要通过替换它们来告诉工具仅使用主模块中的属性。因此您需要使用tools:replace。详情请阅读developer.android.com/studio/build/manifest-merge.html
    【解决方案2】:

    注意:将此添加到您的build.gradle 并确保您使用的是相同的versions as '26.0.2' -

        configurations.all {
        resolutionStrategy.eachDependency {
        DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '26.0.2'
             }
          }
        }
     }
    

    【讨论】:

      猜你喜欢
      • 2016-06-16
      • 1970-01-01
      • 2019-10-23
      • 2015-03-21
      • 2016-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多