Android: Enable ADB Backup for Any App

Android allows the backup and restore of an app’s private data using adb backup. This feature is enabled if the android:allowbackup attribute is set to true in the Android Manifest (AndroidManifest.xml) XML file. If the feature is disabled, ADB backups will not work. In this article we will learn how to enable ADB backups for any app without rooting.

Android ADB Backup Feature

The Android ADB backup feature using adb backup is only available from Android 4.0 (or ICS). To use this feature, USB debugging (under Settings -> Developer options) must be enabled on the device.

Also, this feature does not work on all apps. To enable ADB backup for an app, that app must have set the android:allowbackup attribute to true in the Android Manifest (AndroidManifest.xml) XML file.

Apps like the Google Authenticator and WhatsApp have disabled the ADB backup feature to prevent sensitive information from being extracted from the device.

Overview of Enabling ADB Backup

To enable the ADB backup of an app, we will need to set the android:allowBackup attribute to true. To do that, we will need to:

  1. Download or get a copy of the original APK file
  2. Decompile the APK
  3. Set android:allowBackup attribute to true in AndroidManifest.xml file
  4. Recompile the APK and sign it with our own keys

Tools Required

For this tutorial, you will need the following tools to be installed:

  • Java JDK – for keytool and jarsigner
  • Android SDK – for adb and zipalign
  • Apktool – to decompile ad recompile APKs
  • A text editor, any text editor will do depending on the platform you are working on.
  • Android mobile phone with USB debugging enabled

This article will not cover the installation of the tools mentioned above. Installing the tools are quite straight forward, except maybe for Apktool. To install Apktool, refer to the Apktool install guide.

Before proceeding further, make sure that the PATH environment variable includes the Java SDK, Android SDK and Apktool binaries. All our work will be done within a directory called work within your home directory.

$ mkdir ~/work
$ cd ~/work

Download and Decompile APK

I already have an article documenting the process of decompiling APKs. So, I am not going to duplicate the content over here. Refer to the article for instructions on how to download and decompile the APK.

Enable ADB Backup Feature

The decompiled code should found at work/out directory within your home directory. Edit the AndroidManifest.xml and set the android:allowbackup attribute to true.

$ vi ~/work/out/AndroidManifest.xml

You can also use the following sed command to toggle the value of the attribute found in the AndroidManifest.xml file.

$ sed -i -e "s/android\:allowBackup\=\"false\"/android\:allowBackup\=\"true\"/" ~/work/out/AndroidManifest.xml

Recompile and Install APK

Again, this process has been documented in this article. Generate the keys to sign the app if this is the first time you are doing this. Else, reuse the same key that you generated before to sign the APK. Follow the “Generate Keys” and “Recompile APK” sections for more info.

Final Words

You will need to uninstall the original APK before you can install the modified APK else you will get an error. When you uninstall the original APK, you will lose the app’s private data.

With the modified APK installed on your phone, you will be able to perform ADB backups. But take note that you will not be able to install any new updates for the app from the Play Store. This is due to the fact that the keys used to sign the app are different.

To use an updated app available on the Play Store, you will need to get a copy of the new APK file, decompile the APK, modify the AndroidManifest.xml file, recompile the APK and sign using the same original key that you used previously.

ibrahim = { interested_in(unix, linux, android, open_source, reverse_engineering); coding(c, shell, php, python, java, javascript, nodejs, react); plays_on(xbox, ps4); linux_desktop_user(true); }