美文网首页
Android 关闭备份模式 allowBackup=false

Android 关闭备份模式 allowBackup=false

作者: 南窗云 | 来源:发表于2018-10-26 10:36 被阅读0次

使用 Testin 检测项目,有一个未关闭备份模式的高危风险

APP 开启了数据备份和恢复的功能时,可通过 ADB 备份数据,存在信息泄露的风险

风险信息

修改

在 AndroidManifest.xml 配置文件中显式配置 android:allowBackup=false。

项目中代码 allowBackup="true" 改为 allowBackup=false

    <application
        android:name=".ui.application.RiseApp"
        android:allowBackup="false"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

报错:

Error:
    Attribute application@allowBackup value=(false) from AndroidManifest.xml:38:9-36
    is also present at [:lib_media] AndroidManifest.xml:21:9-35 value=(true).
    Suggestion: add 'tools:replace="android:allowBackup"' to <application> element at AndroidManifest.xml:36:5-197:19 to override.

原因是项目中还有其他 子Module ,也配置了该属性为 true

按照错误提示,给清单文件添加 tools:replace="android:allowBackup 属性

    <application
        android:name=".ui.application.RiseApp"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        tools:replace="android:allowBackup"
        android:theme="@style/AppTheme">

并在顶部添加 xmlns:tools="http://schemas.android.com/tools" ,就可以了

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"

相关文章

网友评论

      本文标题:Android 关闭备份模式 allowBackup=false

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