美文网首页android开发Android
Manifest merger failed with mult

Manifest merger failed with mult

作者: 码农翻身记 | 来源:发表于2019-06-13 15:53 被阅读0次

1、问题
项目合并第三方提供的aar,报错:

Manifest merger failed with multiple errors, see logs

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

org.gradle.api.tasks.TaskExecutionException: Execution failed for task '...:processDebugManifest'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:103)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:73)
at ...

2、查原因
用下面的命令可以打印更详细的日志:

gradlew processDebugManifest -stacktrace 

详细日志:

...\src\main\AndroidManifest.xml:71:9-43 Error:
        Attribute application@icon value=(@mipmap/ic_launcher) from AndroidManifest.xml:71:9-43
        is also present at [:xxx-release:] AndroidManifest.xml:25:9-45 value=(@drawable/ic_launcher).
        Suggestion: add 'tools:replace="android:icon"' to <application> element at AndroidManifest.xml:68:5-4094:19 to override.

3、解决
当我们项目Manefest的某些属性和第三方库中Manefest的属性有冲突会报上面的错误。
比如第三方库中也定义了icon、allowBackup等属性,且会与你的项目不同,则发生冲突,编译就会报错。
解决办法就是在我们项目的Application节点中加入tools:replace来替换三方库中的相关属性,如下:

<application
 ...
 tools:replace="android:allowBackup,android:icon">

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

相关文章

网友评论

    本文标题:Manifest merger failed with mult

    本文链接:https://www.haomeiwen.com/subject/seusfctx.html