2

I have an old application that I've been updating by adding android backup service. I use a BackupAgent to take the content from a table in my SQLite database and write it to a JSON file and then upload it. I've used http://developer.android.com/guide/topics/data/backup.html as reference when coding this.

It works great on my Nexus 5 which runs Android 6.0 Marshmallow. onBackup is called when it's supposed to and so is onRestore. The problem occurs when I try the application on devices that run Lollipop (and probably devices that are pre-Lollipop).

Unable to restore package com.zecave.petter.zeblocker

Is the output from the console when I use bmgr and I'm using the Lollipop devices.

LogCat gives me this message:

02-19 15:59:07.892: E/RestoreSession(948): java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.backup.d.r.a(android.content.Context)' on a null object reference

Does someone know why this works on my Nexus 5 with Marshmallow but not on the two devices I've tried that runs Lollipop? The above message doesn't make any sense to me as I'm not calling the restore from code but from the command line.

Part of the manifest:

    android:allowBackup="true"
    android:icon="@drawable/icon_lightgreen"
    android:label="@string/app_name"
    android:theme="@style/MyMaterialTheme"
    android:restoreAnyVersion="true"
    android:backupAgent="com.zecave.petter.zeblocker.tools.BlacklistBackupAgent" >

    <meta-data android:name="com.google.android.backup.api_key" android:value="AEdPqrEAAAAINjrn1*..." />

I have tried both

android:backupAgent=".tools.BlacklistBackupAgent" 
android:backupAgent=".BlacklistBackupAgent" 

But with the same result.

Edit: See the comment below for further explanation. Apparently it's not only my application that gives this error when trying to restore on the Lollipop devices.

Petroj
  • 21
  • 3
  • This is weird. After some more investingation the exception is not only thrown when trying to restore my own application, but with all the applications that I've tried. This is happening on my own device and my significant others device that is running Lollipop. Syncing of appdata is enabled (I mean, I can backup, but not restore). The Nexus 5 with Marshmallow doesn't have this issue. – Petroj Feb 22 '16 at 07:47
  • Possible duplicate of [BackupAgent: "unable to restore package ..."](https://stackoverflow.com/questions/4662952/backupagent-unable-to-restore-package) – live-love Feb 18 '18 at 01:07

1 Answers1

0

Try changing the transport to:

adb shell bmgr transport android/com.android.internal.backup.LocalTransport

Google imposes a backup limit, and maybe that's why the why the data is not being backed up.

live-love
  • 48,840
  • 22
  • 240
  • 204