54

有人在 Nexus 6P 设备上遇到过这个问题吗?我只在 Nexus 6P(运行 Google Fi)上遇到这个问题。

当我安装应用程序时,userIsLoggedIn里面有一个密钥SharedPreferences

这个块:

boolean userIsLoggedIn  = SharedPrefs.userIsLoggedIn(this);

// Then in another class...

 public static boolean userIsLoggedIn(Context context) {
    // For users updating apps, if the previous key-value is a string, convert it to boolean
    try {
        return context.getSharedPreferences(LOGIN_FILE, Context.MODE_PRIVATE)
                .getBoolean(USER_LOGGED_IN, false);
    } catch (ClassCastException e) {
        Logger.e(TAG, e.getMessage());
        context.getSharedPreferences(LOGIN, Context.MODE_PRIVATE)
                .edit()
                .putBoolean(USER_LOGGED_IN, false)
                .commit();
        return context.getSharedPreferences(LOGIN, Context.MODE_PRIVATE)
                .getBoolean(USER_LOGGED_IN, false);
    }
}

现在这应该false在新的卸载时返回,但在全新安装时调试它我在 App Startup 上得到以下信息。

在此处输入图像描述

如果这很重要,我也会运行 Proguard,当在未启用 proguard 的 APK 上运行设备时,它运行正常。在任何其他设备上运行 proguard 运行良好。

4

3 回答 3

96

由于 Nexus 6P 运行的是 Android M,我认为自动备份是问题所在。

我认为您可以使用allowBackup来阻止它。

检查这个答案:https ://stackoverflow.com/a/32010582/336312

于 2016-01-27T05:26:48.647 回答
19

在 android M 及以上版本中,他们将应用程序备份保存在 google 驱动程序中,您可以通过使用禁用此功能,转到应用程序部分下的项目清单文件设置为 false。你很高兴。android:allowBackup="true"

于 2017-10-03T04:13:43.040 回答
14

您可以添加到清单中:

        android:fullBackupContent="false"
于 2018-04-16T13:51:02.807 回答