Android Studio 解决Manifest merger

作者: 代码君_Coder | 来源:发表于2019-04-11 17:00 被阅读10次

一、产生的经由

用安全工具测试apk漏洞时发现以下安全风险:


image.png

于是我就在Manifest中改过来

<application
    android:allowBackup="false"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme"
>

本以为解决了,改完后,编译又出现新问题

Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed with multiple errors, see logs

网上查了一下问题:找到了解决方案,亲测有效,再此记录下来,便于后人查阅

  1. 首先加上命名空间
xmlns:tools="http://schemas.android.com/tools"
image.png
  1. 然后再加入tools:replace="android:allowBackup"
<application
    android:allowBackup="false"
    tools:replace="android:allowBackup"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme"
>

二、为何如此修改

原因是其他Library与主项目配置了相同allowBackup属性,系统不知道用谁的,加入上面的代码,可以告知编译器,用主项目的配置

公众号

相关文章

网友评论

    本文标题:Android Studio 解决Manifest merger

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