Search code examples
androidxmlandroid-serviceandroid-backup-service

BackupManagerService: Unable to finalize restore


After an update to an application, I've checked and it seems all user's data was deleted for no apparent reason. Examining the logcat shows a few suspicious lines:

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

When this problem occurs the app's AndroidManifest had:

android:allowBackup="true"

For testing purpose I've generated a new apk with

android:allowBackup="false"

After changing it to false it doesn't happen.

What can cause this problem?


Solution

  • The crucial line is this one:

    Restore manifest signatures do not match installed application.

    Which may happen when you backup in release mode and restoring happens in debug mode or vice versa. The exception is thrown in BackupManagerService#restoreFinished().

    In order to manually remove the backup follow this steps.