[Android Software/Hacking General [Developers Only]] scandiun:
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/command-line/zipalign.html

http://stackoverflow.com/questions/19543520/zipalign-verification

http://stackoverflow.com/questions/8300822/android-how-to-find-which-platform-version-an-apk-targets

https://github.com/WhisperSystems/Signal-Android/wiki/How-to-build-Signal-from-the-sources

https://shatter-box.com/knowledgebase/android-apk-signing-tool-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.