我一直试图在我的应用程序上实施备份超过一个月,但直到现在都没有成功.
我完成了Google文档通知的每个步骤:
在Google服务上注册
Manifest上的更改(allowBackup,backupAgent和backup.api_key(google服务注册)等等…
我完成了Google文档通知的每个步骤:
在Google服务上注册
Manifest上的更改(allowBackup,backupAgent和backup.api_key(google服务注册)等等…
清单部分:
<application android:allowBackup="true" android:backupAgent="my.package.MyBackupManagerClass"> <Meta-data android:name="com.google.android.backup.api_key" android:value="my-generated-key-by-google-service" />
事实上,备份正在运行,但只使用本地传输,我已经使用bmgr备份/运行/恢复进行了测试:
bmgr list transports * android/com.android.internal.backup.LocalTransport com.google.android.gms/.backup.BackupTransportService
但是当尝试使用Google传输(云:com.google.android.gms / .backup.BackupTransportService)时,它无效,甚至无法从MyBackupAgentHelper调用我的onCreate().
我要提到的一点是,当我跑:
bmgr备份
bmgr跑
在运行命令之后,在logcat上显示了很多“现在暂存备份”(也显示我的应用程序包在此列表中)但它发生得非常快并且看起来事实上并没有完成备份,毕竟,甚至我的MyBackupHelper.onCreate()未被调用:
02-12 21:13:28.889: D/BackupManagerService(547): Now staging backup of com.google.android.talk 02-12 21:13:28.904: D/BackupManagerService(547): Now staging backup of com.google.android.dialer 02-12 21:13:28.907: D/BackupManagerService(547): Now staging backup of com.android.providers.settings 02-12 21:13:28.910: D/BackupManagerService(547): Now staging backup of com.sirma.mobile.bible.android 02-12 21:13:28.914: D/BackupManagerService(547): Now staging backup of com.android.sharedstoragebackup 02-12 21:13:28.919: D/BackupManagerService(547): Now staging backup of com.google.android.gm 02-12 21:13:28.922: D/BackupManagerService(547): Now staging backup of com.android.providers.userdictionary 02-12 21:13:28.926: D/BackupManagerService(547): Now staging backup of com.google.android.apps.genie.geniewidget 02-12 21:13:28.963: I/GmsBackupTransport(1409): Next backup will happen in 86399923 millis. 02-12 21:13:28.967: I/BackupManagerService(547): Backup pass finished.
解决方法
我有相同的情况 – 当我运行手动备份(通过adb shell命令)工作,但只使用本地传输.对我来说,解决方案是发布Google Play服务,因为我已经测试了数据备份服务而没有发布GP服务.如果您正在使用Proguard,请检查您的proguard配置