5

I want to reinstall the OS on my OnePlus phone running Android 12. Before I do that I would like to backup some of my apps which don't store their data in the cloud. The phone is not rooted, so I have tried using Helium which is apparently dead, but I still tried it. While trying to enable it I found that my phone wasn't recognized by adb as a device, but this was fixed by adding the backup password, but the app just crashes when trying to backup briefly displaying this:

Helium error message

As you can see it also clicks on the "set password" option which just opens desktop. The funny thing is: I don't think I can disable the password now, so...

So after this didn't work I tried looking into backing up with ADB in PowerShell on my Windows 11 pc, but It seems to have issues with doing backups.

To list the files I just do:

adb shell pm list packages -f -3

Let's say that out of those I would like to backup this one:

package:/data/app/~~yCw1hZQNzK2LConsvhuejg==/com.rovio.BadPiggiesHD-pMe0TFd1aaE5-WduzwZ1Zw==/base.apk=com.rovio.BadPiggiesHD

It pulls the .apk file no problem with this command:

adb pull "/data/app/~~yCw1hZQNzK2LConsvhuejg==/com.rovio.BadPiggiesHD-pMe0TFd1aaE5-WduzwZ1Zw==/base.apk" ".\BP.apk"

Although, a little suspicious that it is only 58MB when it should be more like 170.

But trying to make a backup with this line:

adb backup "/data/app/~~yCw1hZQNzK2LConsvhuejg==/com.rovio.BadPiggiesHD-pMe0TFd1aaE5-WduzwZ1Zw==/base.apk=com.rovio.BadPiggiesHD"

generates an empty backup.ab file (literally 0B) even if I pass just com.rovio.BadPiggiesHD as an argument.

I have also tried using the advice from this post and adding quotes around the arguments, so ideally it I want something like this since I need both an apk and data:

adb backup "-apk com.rovio.BadPiggiesHD -f C:\Users\name\Desktop\app_backups\

But this just spits out Now unlock your device and confirm the backup operation. and stops instantly without doing anything.

I have even tried:

adb backup "-apk -shared -all -f C:\Users\name\Desktop\app_backups\full_backup.ab"

I don't need all apps, but this generates an empty file too.

What is the cause of this issue? I am at a loss since there are no error messages.

Andrew T.
  • 16,898
  • 10
  • 77
  • 134
user9102437
  • 153
  • 2
  • 5

1 Answers1

5

Lets get through your questions:

Using adb backup on Android 12+ devices

adb backup is mostly useless on Android devices running Android 12+, it will only work for apps that have been developed and released before Android 12.

For apps that target Android 12 (API level 31) or higher, when a user runs the adb backup command, app data is excluded from any other system data that is exported from the device.

For more details see my answer to Does adb backup/restore still work because it says it's deprecated?

Pulled APK file via adb is a bit small

Although, a little suspicious that it is only 58MB when it should be more like 170. adb pull "/data/app/~~yCw1hZQNzK2LConsvhuejg==/com.rovio.BadPiggiesHD-pMe0TFd1aaE5-WduzwZ1Zw==/base.apk" ".\BP.apk"

On recent Android devices apps are not downloaded from Google Play Store as single APK file but as bunch of split APKs. You can see that in adb shell pm path com.example.someapp as it will output multiple APK files for one app. You need all of them, otherwise the app will not work.

For details how to extract split APK files from a device see the question How to get a split apk from a device via adb?

adb backup /data/app/<somepath>/base.apk does not work

The command adb backup does accept as arguments only app package names, never a path to a file on the device. Therefore this command will never work.

Backup everything (data+apps) via adb creates empty file

If you execute a command like adb backup "-apk -shared -all -f backup.ab and it does create an empty file, it could be that the backup binary bu is bugged or missing on your device.

If you execute a command like adb backup <arguments>, an adb connection will be established and on the device the command bu <arguments> will be executed. I have seen devices where the bu command was simply defect. You can test this by opening adb shell yourself and then try to execute bu --help. If this prints an error message or may be even /system/bin/sh: bu: inaccessible or not found then adb backup can not work on your device.

Robert
  • 22,621
  • 6
  • 54
  • 76