Manifest merger failed with multiple errors, see logs 问题处理

首先致谢: https://www.jianshu.com/p/a22c55a28064, 我们不生产代码, 我们只做大自然的搬运工!

 

一.【问题背景】 项目导入第三方(OPPO 和魅族 厂商推送)提供的aar 文件,报错

错误描述:Manifest merger failed with multiple errors, see logs

打开详细gradle报错日志,发现是执行任务processDebugManifest报错:

 

 

 

 

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:processDebugManifest'
Caused by: java.lang.RuntimeException: Manifest merger failed with multiple errors, see logs
    at com.android.builder.core.AndroidBuilder.mergeManifestsForApplication(AndroidBuilder.java:558)
    at com.android.build.gradle.tasks.ProcessApplicationManifest.doFullTaskAction(ProcessApplicationManifest.java:208)
    at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:106)

 

二. 【原因定位】使用命令查看更详细日志

gradlew processDebugManifest -stacktrace 

详细日志:

uses-sdk:minSdkVersion 17 cannot be smaller than version 19 declared in library [:com.heytap.msp:] C:\Users\Mostone-0030\.gradle\caches\transforms-2\files-2.1\812e2e860b0bf2a7996e395481d6e5c9\AndroidManifest.xml as the library might be using APIs not availa
ble in 17
        Suggestion: use a compatible library with a minSdk of at most 17,
                or increase this project's minSdk version to at least 19,
                or use tools:overrideLibrary="com.heytap.mcssdk" to force usage (may lead to runtime failures)


See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.

 

三. 【解决方案】

当我们项目Manefest的某些属性和第三方库中Manefest的属性有冲突会报上面的错误。
比如第三方库中也定义了icon、allowBackup等属性,且会与你的项目不同,则发生冲突,编译就会报错。
解决办法就是在我们项目的Application节点中加入tools:replace来替换三方库中的相关属性,如下:(根据实际情况)
<application
 ...
 tools:replace="android:allowBackup,android:icon">
 ...
 <uses-sdk tools:overrideLibrary="com.heytap.mcssdk,com.meizu.cloud.pushinternal" />

还有一种方案就是去掉第三方库中冲突的属性。

 

总结: 核心代码

使用命令查看更详细日志,快速定位bug 并解决

gradlew processDebugManifest -stacktrace 
上一篇:一次kafka报错记录 : kafka.errors.NoBrokersAvailable


下一篇:【SpringMVC】标签库:errors