FORUMS
Remove All Ads from XDA

[GUIDE] How to enable adb backup for any app changing android:allowBackup

1,765 posts
Thanks Meter: 947
 
By scandiun, XDA Ad-Free Senior Member on 6th November 2016, 07:13 PM
Post Reply Email Thread
Some applications can't be backed up by adb backup because the option is disabled on the AndroidManifest.xml of the apk. To workaround this, it is required to set android:allowBackup to true in the AndroidManifest.xml.

The application I will be patching is Signal Private Messenger, which by default doesn't allow adb backups (security reasons, I guess). Also, it's an open source application:
Signal Private Messenger (Play Store)
Signal Private Messenger (GitHub)

CHECKING FLAG_ALLOW_BACKUP
The first step is to check if the flag FLAG_ALLOW_BACKUP is present. It can be done several ways, but the easiest one is to use System Info for Android or System Info Pro for Android to check the flags of any desired application. Of course using Windows or Linux you can use script to auto-check for any number of apks.
You will see that in the app "Signal Private Messenger" the flag is missing with the official version:



Analyst also displays FLAGS per app. In this screenshot you can see Signal already patched:



APK EASY TOOL (WINDOWS APPLICATION)
To decompile, compile and sign the modified apk, the APK Easy Tool is the best to go, all in one with no complication. It requires java SDK installed and "java" and "javac" to be present on your PATH:
[TOOL] APK Easy Tool v1.2 for Windows (GUI tool, friendly)

Once you've executed "APK Easy Tool v1.2.exe", go to Options and configure "Decompiled directory" and "Compiled directory". You can just hit "Setup directories for me" and the folders will be set automatically to default locations:



Then go to the main tab of the program and leave checked "Sign APK after compile". Hit "Select" on "APK File to work on" and Decompile:



Now on your "Decompiled APKs" folder (you can use directly the button on the main windows of the program), open the file AndroidManifest.xml with a text editor. Notepad++ is highly recommended.

Then replace
android:allowBackup="false"
with
android:allowBackup="true"

After that, save the file and close the text editor. Now go back to APK Easy Tool and hit Compile to build the modified version of Signal Private Messenger. It will be present on the "Compiled directory".

APK EDITOR PRO (ANDROID APPLICATION)
APK Editor Pro is the way to go if you want to edit the file directly on the smartphone. First, you need to get the Signal apk from the smartphone, with some app like APK Extractor Pro.

Open the extracted Signal apk with the apk editor and edit the AndroidManifest.xml. Save and it will automatically compile and sign the new version.

Note that APK Editor Pro is very prone to errors, so it's highly recommender to use the APK Easy Tool instead. Just try and error.

REINSTALL APP
To install on android the patched apk, you must first uninstall your previous version, and this is because the key used to sign the apk is different. If you try to install one app itself with a different signing key, you will get this error: [INSTALL_FAILED_ALREADY_EXISTS]

Now you can see that FLAG_ALLOW_BACKUP is present:



There are some things to have in mind when using apks signed with unofficial keys:
  • The app will no be updated anymore automatically from Google Play Store or any other store, because you are using a custom key. You must surveil periodically the store where you get the updates, download the newer apk, patch it and update it. The developer may or may not modify flags with future updates.
  • You can uninstall the patched app at any time to reinstall the official one from Play Store, but you will lose app's data if you don't perform a valid backup before.
  • Signing keys have an expiration date. The one used by APK Easy Tool is valid for a lot of years so shouldn't be a worry.
  • The apks generated by APK Easy Tool are not zipaligned, but they will work perfectly the same. The only difference is that they will consum a little more of RAM.
  • If you modify several apks, it's better to use the same signing key for ease of updating.

OTHER METHODS AND LINKS
There are a lot of methods to decompile, edit, recompile, sign and zipalign apks. I will provide some useful links with other software and development information:

https://developer.android.com/studio.../zipalign.html
http://stackoverflow.com/questions/1...n-verification
http://stackoverflow.com/questions/8...an-apk-targets
https://github.com/WhisperSystems/Si...om-the-sources
https://shatter-box.com/knowledgebas...ol-apk-signer/
[IDE][3.x] APK Studio - IDE for Reverse Engineering Android APKs
Decompile, Edit, and Recompile in One Tool with APK Studio
Idea: Hook "android:allowBackup" in AndroidManifest.xml
[XPOSED][MOD] Backup All Apps
[INDEX] Xposed Modules Collection | Post Modules' Requests Here!
ADB Backup and Restore not all it's cracked up to be.
The Following 2 Users Say Thank You to scandiun For This Useful Post: [ View ] Gift scandiun Ad-Free
17th December 2016, 06:16 PM |#2  
Senior Member
Thanks Meter: 9
 
More
Is there a version of APK Easy Tool for Mac OS? Thanks!
22nd September 2018, 07:01 PM |#3  
Praetoriani's Avatar
Senior Member
Flag Munich
Thanks Meter: 16
 
More
Question backup of apps fails despite android: allowBackup="true"
I tried to backup some apps using following ADB-Command:
adb backup -apk -obb -noshared apk.package.name -f C:\Destination\Folder\package_backup.ab
But it didn't work for all my apps.

I started searching for an explanation and a solution for my Problem. Then I found your guide and followed the instructions.
But when I decompiled some of these apps I wasn't able to create a backup, I recognized that some of them had the flag android:allowBackup="true"

Here are a few of these apps (just to name a few):
» app.WTInfoTech.WorldAroundMeLite.apk
» appplus.mobi.lockdownpro.apk
» cn.wps.moffice_eng.apk
» color.dev.com.pink
In reality, there are far more apps than just four.
There are certainly around 40-50 apps that can not be backed up using ADB (even though they have the appropriate flag in the AndroidManifest.xml)

I am using the latest Plattform Tools for Windows (r28.0.1) downloaded from here

Can someone explain to me, why I cannot backup these apps? Even if they have the android:allowBackup="true" flag?
Am I doing something wrong? Or is there some kind of a magic trick that I don't know?

I would be very happy if someone could help me with this problem.
27th October 2018, 06:53 AM |#4  
Junior Member
Thanks Meter: 3
 
More
I've been having this problem as well. I noticed that not all apps are backed up using the all flag etc.
I think it boils down to if the app uses a backup agent. Looking at the logcat when attempting to backup ConnectBot using the command adb -apk -obb -f backup.ab org.connectbot It said connect bot is Key-Value and just silently skips it. When using the command adb -apk -obb -keyvalue -f backup.ab org.connectbot It will actually backup some data, but it will not backup the apk.
I don't really have a solution just wanted to share some observations.

Quote:
Originally Posted by Praetoriani

I tried to backup some apps using following ADB-Command:
adb backup -apk -obb -noshared apk.package.name -f C:\Destination\Folder\package_backup.ab
But it didn't work for all my apps.

I started searching for an explanation and a solution for my Problem. Then I found your guide and followed the instructions.
But when I decompiled some of these apps I wasn't able to create a backup, I recognized that some of them had the flag android:allowBackup="true"

Here are a few of these apps (just to name a few):
» app.WTInfoTech.WorldAroundMeLite.apk
» appplus.mobi.lockdownpro.apk
» cn.wps.moffice_eng.apk
» color.dev.com.pink
In reality, there are far more apps than just four.
There are certainly around 40-50 apps that can not be backed up using ADB (even though they have the appropriate flag in the AndroidManifest.xml)

I am using the latest Plattform Tools for Windows (r28.0.1) downloaded from here

Can someone explain to me, why I cannot backup these apps? Even if they have the android:allowBackup="true" flag?
Am I doing something wrong? Or is there some kind of a magic trick that I don't know?

I would be very happy if someone could help me with this problem.

27th October 2018, 11:18 AM |#5  
Praetoriani's Avatar
Senior Member
Flag Munich
Thanks Meter: 16
 
More

@dazoe
THX for sharing your knowledge
I'm going to check my logcat as well for these apps adb does not back up
I can give you a short guide on how to extract/backup an apk of a specific package:

1) If you don't know the package-name, you can create a list of all installed packages (sorted in alphabetical prder without app names)
adb shell pm list packages -f | sed -e 's/.*=//' | sort

2) Now look for the desired app you want to extract/backup the apk from. Then run following command:
adb shell pm path com.example.someapp
You will get an output which will look something like the following:
package:/data/app/com.example.someapp-1/base.apk

3) With this information you can simply perform a pull-command like the following:
adb pull -a -p /data/app/com.example.someapp-1/base.apk C\LOCAL\PATH\TO\YOUR\BACKUP\com.example.someapp-1/base.apk

Hope that I could help you with this little guide

1st December 2018, 10:07 PM |#6  
Junior Member
Thanks Meter: 6
 
More
I patched the apk I want to backup, but before I uninstall the original and install the patched, are there any other methods that will allow me to restore my original appdata? Since uninstalling the original will remove that appdata. I'm not rooted.
24th January 2019, 07:17 PM |#7  
Junior Member
Thanks Meter: 0
 
More
so whats the point if you have to uninstall the app and reinstall using the new apk? itll wipe the data of the app you're trying to back up

is there any way to do this without wiping?
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes