8

I've been trying to implement the backup on my app for more than a month, but no success till now. I had done every steps that Google docs inform: Registered on Google Service Changes on Manifest (allowBackup, backupAgent and backup.api_key (google service register) and so on...

Manifest parts:

<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" />

In fact, the backup is working, but only using the Local transport, I had tested using bmgr backup/run/restore:

bmgr list transports
  * android/com.android.internal.backup.LocalTransport
    com.google.android.gms/.backup.BackupTransportService

But when trying to use the Google transport (cloud: com.google.android.gms/.backup.BackupTransportService) it does not works, not even call my onCreate() from MyBackupAgentHelper.

One point that I want to mention is that when I run: bmgr backup bmgr run

After run command, on the logcat shows a lot of "Now staging backup of " (also shows my apps package on this list) but it happens very fast and don't seems that the backup is being done in fact, after all, even my MyBackupHelper.onCreate() is not called:

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.
ArtKorchagin
  • 4,801
  • 13
  • 42
  • 58
JonasOliveira
  • 694
  • 8
  • 26
  • You should post your manifest so we can make sure that you've registered the service and the backup agent correctly. – Reuben Tanner Mar 06 '15 at 19:50
  • @Kairos, I had added the manifest info on the question. – JonasOliveira Mar 06 '15 at 21:20
  • Is this on an emulator or a physical device? – Reuben Tanner Mar 07 '15 at 23:12
  • Physical. Nexus 4 and I had testes also with Moto G – JonasOliveira Mar 08 '15 at 02:41
  • And are you sure that you've got fresh data from the previous back up? The BackupManager only backs up data if it has been changed from the previous back up. – Reuben Tanner Mar 09 '15 at 14:44
  • Yes. I had done a lot of tries with changing data, calling onDataChanged. The backup is working, but only selecting the transport as LOCAL, but using the google it does not works. – JonasOliveira Mar 09 '15 at 21:51
  • Hi @jonas I'm with the same problem. I also found this project that seems to have the backup implemented https://github.com/AndlyticsProject/andlytics and I did it on the same way. But is not working. Could you describe what you mentioned "The backup is working, but only selecting the transport as LOCAL" Thanks! – Pablo Mar 11 '15 at 18:07
  • To use local transport the backup will be done in your de vice, not on google server. Use `bmgr list transports` then copy the local ttansport and set it as: `bmgr transport set `. Now test your backup manager. – JonasOliveira Mar 12 '15 at 01:55
  • Hi JonasOliveira: did you find the reason? I have the same issue. I tested on XperiaZ2. Thanks! – LHA May 01 '15 at 13:03
  • No... I gave up on this because I also did not find anyone else that got this backup wonking. – JonasOliveira May 02 '15 at 01:44

1 Answers1

1

I had the same situation - when i run manual backup (through adb shell command) is working, but only using the Local transport. For me the solution was to publish Google Play services, because I've tested data backup service without published GP services. Check your proguard configuration also if you're using Proguard

Bero
  • 990
  • 7
  • 12
  • 1
    what do you mean by "to public Google Play services"? Which configuration on Proguard we can check? Thanks! – JonasOliveira Mar 31 '16 at 11:33
  • I've prepared new application and I have not released Google Play services for the first time. So for me it was to: 1. Release (public) Google Play services and add this line to proguard ( -keep class * extends android.app.backup.BackupAgentHelper ). I don't know if this line in proguard is necessary. – Bero Apr 01 '16 at 18:28
  • Ok got it. So maybe the backup on network only works after you publish the application? When I was testing my application also was not published yet on Google Play. – JonasOliveira Apr 05 '16 at 12:40
  • Maybe it is. Could you publish application and test if it will be working for you? I've tested backup one day after publish Google Play. – Bero Apr 06 '16 at 09:16
  • In fact I have already published my application time ago, but also I had implemented another backup solution. But for now I'm not able to test it. But I will do in the future. But if it worked for you and I think that your point is the solution I will mark as answer. – JonasOliveira Apr 06 '16 at 12:18