BackupManagerService:无法完成还原

BackupManagerService: Unable to finalize restore

应用程序更新后,我检查了一下,似乎所有用户的数据都被莫名其妙地删除了。 检查 logcat 显示了一些可疑行:

04-11 15:06:17.877 32429-17597/? I/Backup: [GmsBackupTransport] Current restore package : PackageInfo{8f777e2 com.my.package}

04-11 15:06:17.878 24281-26232/? I/BackupManagerService: Next restore package: RestoreDescription{com.my.package : STREAM}

04-11 15:06:22.910 24281-32369/? W/RestoreEngine: Restore manifest signatures do not match installed application for com.my.package

04-11 15:06:27.183 24281-26232/? E/BackupManagerService: Unable to finalize restore of com.my.package

04-11 15:06:27.184 24281-26232/? I/ActivityManager: Force stopping com.my.package appid=10389 user=0: clear data

04-11 15:06:27.189 24281-24345/? I/ActivityManager: Force stopping com.my.package appid=10389 user=-1: clearApplicationUserData

04-11 15:06:27.225 24281-26232/? D/BackupManagerService: Restore complete, killing host process of com.my.package

发生此问题时,应用的 AndroidManifest 有:

android:allowBackup="true"

出于测试目的,我生成了一个新的 apk

android:allowBackup="false"

改成false后就没有了。

什么会导致这个问题?

关键是这一行:

Restore manifest signatures do not match installed application.

当您在发布模式下备份而在调试模式下恢复时可能会发生这种情况,反之亦然。 BackupManagerService#restoreFinished().

抛出异常

要手动删除备份,请执行 this 步骤。