Since yesterday, my Nexus 5 is running Lollipop and the application I am working on is stopping without any crash.
Each time it exits, the device logs the following:
11-20 00:23:32.679: I/ActivityManager(723): START u0 {flg=0x14008000 cmp=com.mycompany.android/.app.LoginActivity} from uid 10549 on display 0
11-20 00:23:32.713: W/ActivityManager(723): Duplicate finish request for ActivityRecord{2cd672e4 u0 com.mycompany.android/.app.StartupActivity t39 f}
11-20 00:23:32.926: I/ActivityManager(723): Displayed com.mycompany.android/.app.LoginActivity: +223ms
11-20 00:23:45.734: I/ActivityManager(723): Force stopping com.mycompany.android appid=10549 user=-1: uninstall pkg
11-20 00:23:45.734: I/ActivityManager(723): Killing 24090:com.mycompany.android/u0a549 (adj 0): stop com.mycompany.android
11-20 00:23:45.793: W/ActivityManager(723): Force removing ActivityRecord{5367f0c u0 com.mycompany.android/.app.LoginActivity t39}: app died, no saved state
11-20 00:23:45.846: W/ActivityManager(723): Spurious death for ProcessRecord{33eaa703 24090:com.mycompany.android/u0a549}, curProc for 24090: null
11-20 00:23:45.853: I/ActivityManager(723): Force stopping com.mycompany.android appid=10549 user=0: pkg removed
11-20 00:23:46.188: D/BackupManagerService(723): Received broadcast Intent { act=android.intent.action.PACKAGE_REMOVED dat=package:com.mycompany.android flg=0x4000010 (has extras) }
11-20 00:24:23.646: E/BackupManagerService(723): Timeout restoring application com.mycompany.android
11-20 00:24:23.647: W/BackupManagerService(723): Tried to clear data for com.mycompany.android but not found
11-20 00:26:49.647: V/BackupManagerService(723): restoreAtInstall pkg=com.mycompany.android token=a restoreSet=3319d18fd0806258
11-20 00:26:50.025: I/BackupTransportService(1752): Current restore app : com.mycompany.android
11-20 00:26:50.027: I/BackupManagerService(723): Next restore package: RestoreDescription{com.mycompany.android : KEY_VALUE}
11-20 00:26:50.028: V/BackupManagerService(723): Package com.mycompany.android restore version [0] is compatible with installed version [0]
11-20 00:26:50.028: W/BackupManagerService(723): Signature mismatch restoring com.mycompany.android
11-20 00:26:50.236: D/BackupManagerService(723): Received broadcast Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.mycompany.android flg=0x4000010 (has extras) }
11-20 00:26:50.240: D/BackupManagerService(723): Now staging backup of com.mycompany.android
It sounds like that the system decides to force stop my application because the restoration times out. It also happens when the app is correctly signed.
BackupManager related implementation was running fine until 4.4.2.
I am currently checking if not invoking any BackupManager APIs works around this unexpected/silent force-stop. For now it looks ok.
Any suggestion?
With gradle in Android Studio you can create a debug directory with an AndroidManifest.xml file for your debug build to disable the BackupManager:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application
android:allowBackup="false"
tools:replace="android:allowBackup">
</application>
</manifest>
来源:https://stackoverflow.com/questions/27029273/backupmanagerservice-restoration-timeout-leads-to-force-stop