0

看起来 myonBackup在我运行时被调用adb shell bmgr run,但是看起来像PolicyException. 有谁知道这意味着什么或是什么原因造成的?我在这里敲我的头。

更新:仅当我尝试使用 BackupTransportService 作为传输时才会发生这种情况。使用 LocalTransport 就好了。不过还是需要帮助!

这是 MyBackupAgent 的代码

public class MyBackupAgent extends BackupAgentHelper {

    @Override
    public void onCreate(){
        Log.d("GradeTracker.MyBackupAgent", "onCreate called");

        FileBackupHelper myDb = new FileBackupHelper(this, "../databases/" + DBAdapter.DATABASE_NAME);
        addHelper(DBAdapter.DATABASE_NAME, myDb); 
    }

    @Override
    public void onBackup(ParcelFileDescriptor oldState, BackupDataOutput data,
         ParcelFileDescriptor newState) throws IOException {
        Log.d("GradeTracker.MyBackupAgent", "onBackup called");
            synchronized (DBAdapter.dbBackupLockObject) {
                    super.onBackup(oldState, data, newState);
            }
    }

    @Override
    public void onRestore(BackupDataInput data, int appVersionCode,
                    ParcelFileDescriptor newState) throws IOException {
            Log.d("GradeTracker.MyBackupAgent", "onRestore called");
            synchronized (DBAdapter.dbBackupLockObject) {
                    super.onRestore(data, appVersionCode, newState);
            }
    }
}

我的清单...

<application
        android:allowBackup="true"
        android:backupAgent="MyBackupAgent" ...>
    <meta-data android:name="com.google.android.backup.api_key" 
            android:value="<myKey>" />     
</application>

堆栈跟踪

11-13 19:53:44.481: D/PerformBackupTask(352): starting agent for backup of BackupRequest{pkg=com.NsouthProductions.gradetrackerpro}
11-13 19:53:44.501: I/BackupManagerService(352): got agent android.app.IBackupAgent$Stub$Proxy@441b7118
11-13 19:53:44.501: D/PerformBackupTask(352): invokeAgentForBackup on com.NsouthProductions.gradetrackerpro
11-13 19:53:44.511: V/BackupServiceBinder(30648): doBackup() invoked
11-13 19:53:44.511: D/GradeTracker.MyBackupAgent(30648): onBackup called
11-13 19:53:44.511: D/BackupHelperDispatcher(30648): handling existing helper 'GradeTracker.db' android.app.backup.FileBackupHelper@425a93e0
11-13 19:53:45.382: E/BackupTransportService(352): com.google.android.backup.BackupRequestGenerator$PolicyException: server error in app com.NsouthProductions.gradetrackerpro: code 7
11-13 19:53:45.382: E/BackupTransportService(352):  at com.google.android.backup.BackupRequestGenerator.parseResponse(BackupRequestGenerator.java:360)
11-13 19:53:45.382: E/BackupTransportService(352):  at com.google.android.backup.BackupTransportService.sendRequestLocked(BackupTransportService.java:849)
11-13 19:53:45.382: E/BackupTransportService(352):  at com.google.android.backup.BackupTransportService.access$600(BackupTransportService.java:78)
11-13 19:53:45.382: E/BackupTransportService(352):  at com.google.android.backup.BackupTransportService$1.finishBackup(BackupTransportService.java:444)
11-13 19:53:45.382: E/BackupTransportService(352):  at com.android.server.BackupManagerService$PerformBackupTask.operationComplete(BackupManagerService.java:2320)
11-13 19:53:45.382: E/BackupTransportService(352):  at com.android.server.BackupManagerService$BackupHandler.handleMessage(BackupManagerService.java:572)
11-13 19:53:45.552: I/PerformBackupTask(352): Backup pass finished.
4

1 回答 1

1

解决了!我的 Android 备份服务密钥显然是坏的。我的清单中的包名中有几个大写字母,所以我想“也许我应该确保我的密钥是使用具有相同大写的包名生成的。” 因此,我从清单中直接复制/粘贴了我的包名称再次注册,我得到了一个不同的密钥,现在似乎可以正常工作。

于 2014-11-14T12:44:10.880 回答