Android自动备份:传输被拒绝的包

时间:2016-11-10 14:30:12

标签: android android-backup-service

我正在尝试测试Android auto backup。我在7.1设备上,应用清单包含:android:fullBackupOnly="true"。当我发出adb shell bmgr backupnow <package>命令时(对于SO帖子我用占位符替换了我的包名),我看起来像是失败了:

Running backup for 1 requested packages.
Package @pm@ with result: Success
Package <package> with result: Transport rejected package
Backup finished with result: Success

如果我将清单更改为android:fullBackupOnly="false"(即使用旧的K / V备份),然后重新发出backupnow命令,我会看到成功:

Running backup for 1 requested packages.
Package @pm@ with result: Success
Package <package> with result: Success
Backup finished with result: Success

在拒绝案例中查看Logcat,我看到以下内容:

11-10 09:27:59.660 1683-1683/? D/AndroidRuntime: Calling main entry com.android.commands.bmgr.Bmgr
11-10 09:27:59.669 1035-2498/? V/PerformBackupTask: Beginning backup of 0 targets
11-10 09:27:59.677 1035-2498/? D/PerformBackupTask: invokeAgentForBackup on @pm@
11-10 09:27:59.685 1035-2498/? I/BackupRestoreController: Getting widget state for user: 0
11-10 09:27:59.691 1035-2498/? D/PerformBackupTask: Starting full backups for: [<package>]
11-10 09:27:59.692 1035-2498/? I/BackupManagerService: K/V backup pass finished.
11-10 09:27:59.693 1035-1699/? I/PFTBT: Initiating full-data transport backup of <package>
11-10 09:27:59.695 12554-12566/? I/Backup: [GmsBackupTransport] Attempt to do full backup on <package>
11-10 09:27:59.697 1035-1699/? I/PFTBT: Transport rejected backup of <package>, skipping
11-10 09:27:59.697 1035-1699/? I/PFTBT: Unbinding agent in <package>
11-10 09:27:59.697 1035-1699/? W/ActivityManager: Unbinding backup agent with no active backup
11-10 09:27:59.697 1035-1699/? I/PFTBT: Full backup completed with status: 0
11-10 09:27:59.697 1035-1699/? I/BackupManagerService: Full data backup pass finished.

这些是相关的行:

11-10 09:27:59.695 12554-12566/? I/Backup: [GmsBackupTransport] Attempt to do full backup on <package>
11-10 09:27:59.697 1035-1699/? I/PFTBT: Transport rejected backup of <package>, skipping

为什么完整/自动备份失败?

以下是成功(K / V)案例的完整Logcat:

11-10 09:31:21.750 2200-2200/? D/AndroidRuntime: Calling main entry com.android.commands.bmgr.Bmgr
11-10 09:31:21.762 1035-2498/? V/PerformBackupTask: Beginning backup of 1 targets
11-10 09:31:21.768 1035-2498/? D/PerformBackupTask: invokeAgentForBackup on @pm@
11-10 09:31:21.775 1035-2498/? I/BackupRestoreController: Getting widget state for user: 0
11-10 09:31:21.780 1035-2498/? D/PerformBackupTask: starting key/value backup of BackupRequest{pkg= <package>}
11-10 09:31:21.783 1035-2498/? D/BackupManagerService: awaiting agent for ApplicationInfo{b68136a  <package>}
11-10 09:31:21.793 1035-1815/? D/BackupManagerService: agentConnected pkg= <package> agent=android.os.BinderProxy@6750684
11-10 09:31:21.793 1035-2498/? I/BackupManagerService: got agent android.app.IBackupAgent$Stub$Proxy@5e82e6d
11-10 09:31:21.793 1035-2498/? D/PerformBackupTask: invokeAgentForBackup on  <package>
11-10 09:31:21.796 1908-1920/ <package> D/BackupAgent: onBackup
11-10 09:31:21.796 1908-1920/ <package> D/BackupHelperDispatcher: handling existing helper 'data'  <package>.io.DbBackupHelper@35d5ebe
11-10 09:31:21.798 1908-1920/ <package> D/BackupHelperDispatcher: handling existing helper 'prefs' android.app.backup.SharedPreferencesBackupHelper@6936b1f
11-10 09:31:21.800 1035-2498/? I/BackupRestoreController: Getting widget state for user: 0
11-10 09:31:21.805 2200-2200/? D/AndroidRuntime: Shutting down VM
11-10 09:31:21.807 1035-2498/? I/BackupManagerService: K/V backup pass finished.

2 个答案:

答案 0 :(得分:0)

https://developer.android.com/guide/topics/data/testingbackup.html处的文档 说以下内容:

  

超出配额

     

如果您在logcat中看到以下消息:

     

I / PFTBT:传输拒绝PACKAGE的备份,跳过

     

---或---

     

I / PFTBT:包装超出运输配额:PACKAGE

     

你的应用有   超过配额,并已被禁止备份数据   设备。要取消禁令,请在出厂时重置设备或进行更改   备份帐户。

答案 1 :(得分:0)

我得到了同样的错误,最后找到了解决方案:

targetSdkLevel中的build.gradle必须设置为 23 或更高。

如果targetSdkLevel设置为例如,项目将在模拟器中编译并运行正常。 21.但是为了能够使用Google Play服务作为备份目的地(我猜我们大多数人都在使用它),它必须至少为23。