1

Say I have "FunnyApp" installed from Playstore, now it turns up at F-Droid – and I want to replace the Playstore version by the F-Droid one (same issue vice-versa). Trouble is, I cannot simply update the app from the new source as the signature doesn't match (F-Droid signs with their own key). FunnyApp doesn't offer any "export" functionality, but I don't want to lose its data.

What would be possible approaches to perform a proper switch?

Traps:

  • Simply updating/installing from "the other source" does not work (signature mismatch)
  • performing a data-only adb backup doesn't help, as the restore will fail for the same reason

I have some vague ideas on root-based solutions which I haven't tried yet (e.g. Titanium Backup might be able to restore data despite of the changed signature, and there's also some XPosed module (InstallerOpts?) offering to "suppress the signature warning"). But before "messing up big" I thought to ask here if someone might already have successfully tried some solution.

Non-root solutions preferred (so more people can profit from), root-based solutions acceptable, XPosed as requirement OK as well.


Some reasons why one might want to "switch sources" (aka "cross-update"): Getting rid of proprietary dependencies, app no longer updated at original source …

2
  • Right, @iBug – the second one was XPrivacy. I alsways confuse which wants the big P and which not. Doesn't really matter in this context, does it? But thanks for your "read confirmation" #D
    – Izzy
    Commented Aug 2, 2017 at 6:29
  • Xposed is ONE word, while XPrivacy is X + Privacy (where X is a common prefix of something being an Xp module, like the iSomething's in App Store).
    – iBug
    Commented Aug 2, 2017 at 7:29

1 Answer 1

2

Rootless

Sorry but AFAIK it's not possible :( I've never seen any app/tool/utility successfully modifying other apps' data, not even reading!
Alternatively you could do that in a custom recovery, but who uses a custom recovery without rooting? So read below.

Simple Root (Manual way)

Don't take it too hard. Just move its original data away, uninstall the original app and install the new one, then move the data back and chown. Sample shell commands are below.

# mv /data/data/com.example.foo /data/media
 * UNINSTALL_ORIGINAL_APP
 * INSTALL_NEW_APP
# ls -ld /data/data/com.example.foo
 * take note of the user (e.g. u0_a123)
# mv /data/media/com.example.foo /data/data
# chown -R 10123.10123 /data/data/com.example.foo

Explanations for each step:

  1. Move original app data to an alternative place. Because Androis automatically delete irrelevant files in certain directories, we need a safe place as the Alt. AFAIK unknown files are ignored in /data/media so that is chosen.
  2. Replace app. No explanation.
  3. Obtain the UID of newly installed app. Wrong UID will make Package Installer delete app data.
  4. Move data back and change UID.

A small note: The builtin chown command does not accept option -R (recursive) by default in Android L or lower. You need BusyBox in that case. In Android M and up it just works fine.

Root Utilities

  • Titanium Backup

    With TiBu you can easily back up existing data, then safely remove the old app and install the new app. Then as long as both packages have the same package name, you can restore the data for the app with TiBu, intact!

    However, this solution is essentially a data-backup, so it will not be maintained here. If you want to learn more about backing up & restoring data, check out our tag wiki for , under the App-based backups section.

Xposed Modules (Easiest, Recommended by iBug)

XInstaller and its successor, InstallerOpt, can hook Package Installer to allow packages with mismatching signatures to be installed (by skipping sig check). Then all your data is preserved and you can easily switch to different versions. This is the method I am currently using and it has been working fine. Sad that Xposed isn't officially available for Android N (so far), so this solution is only for Android M and down.

Theoretically, they should not cause anything wrong because all they do is hooking the signature checking function and change its return value to a truthy value, bypassing the check. If the replacement package have any other defects than mismatching signature, the installation will still fail, so no faulty packages can be installed even if you skip signature check.

Important Notice
It is not recommended to leave that option (skip sig check) enabled all the time. Leaving it enabled will create a big security flaw as hacked apps (almost always use a different signature) can also be installed. I personally enable it only when needed and disable it as soon as I finished my package replacement.

4
  • Is the sample shell command effective?How can I restore again my apps if it didn't work in my android?I would like to have a very clear answer before I try this to my android phone. Commented Aug 14, 2017 at 12:49
  • @JuanitoParungao The sample shell script is exactly what I've done many times without a single failure. Still try it cautiously.
    – iBug
    Commented Aug 14, 2017 at 12:52
  • InstallerOpt worked like a charm, thanks for ensuring me of that :)
    – Izzy
    Commented Aug 24, 2017 at 8:38
  • Are there maintained InstallerOpt/XInstaller alternatives working on Android 9-12 ?
    – KaKi87
    Commented May 28, 2022 at 13:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .