2

Howto downgrade any app to the previous version without losing data on android 8.1 ?

EDIT 0 : Nota Bene : Here, Fairemail is given as an example, my question is not app specific but Android specific. I'm actually asking how to downgrade any app to it's previous release having already downloaded the apk.

Here is the information of the package eu.faircode.email I want to push to downgrade :

$ du -h eu.faircode.email_1036.apk
13M eu.faircode.email_1036.apk
$ aapt2 dump badging eu.faircode.email_1036.apk | egrep '^$|package|[s]dkVersion:|application-label:|native-code:'
package: name='eu.faircode.email' versionCode='1036' versionName='1.1036' platformBuildVersionName='' platformBuildVersionCode='' compileSdkVersion='29' compileSdkVersionCodename='10'
sdkVersion:'21'
application-label:'FairEmail'
native-code: 'arm64-v8a' 'armeabi-v7a' 'x86' 'x86_64'

I tried to reinstall this app without data-loss :

$ adb install -r -d eu.faircode.email_1036.apk
Performing Streamed Install
adb: failed to install eu.faircode.email_1036.apk: Failure [INSTALL_FAILED_VERSION_DOWNGRADE]

but it didn't work, so I tried the un-installation of this app without data loss and it worked :

$ adb uninstall -k eu.faircode.email
The -k option uninstalls the application while retaining the data/cache.
At the moment, there is no way to remove the remaining data.
You will have to reinstall the application with the same signature, and fully uninstall it.
If you truly wish to continue, execute 'adb shell cmd package uninstall -k'.
$ adb shell cmd package uninstall -k eu.faircode.email
Success

But then the installation of eu.faircode.email_1036.apk didn't :

$ adb install eu.faircode.email_1036.apk
Performing Streamed Install
adb: failed to install eu.faircode.email_1036.apk: Failure [INSTALL_FAILED_VERSION_DOWNGRADE]
$ adb install -d eu.faircode.email_1036.apk
Performing Streamed Install
adb: failed to install eu.faircode.email_1036.apk: Failure [INSTALL_FAILED_VERSION_DOWNGRADE]
$ echo $?
1

It seems adb install -d is only use-able with debuggable packages only according to this :

$ adb | grep downgrade
      -d: allow version code downgrade (debuggable packages only)

Can you help me ?

0
3

What you want is not possible and for a good reason: updated data structures (files, database, etc) are often incompatible with old app versions. This is why you can downgrade debuggable packages (for development purposes) only.

If you have a problem with FairEmail, please report it in this forum:

https://forum.xda-developers.com/android/apps-games/source-email-t3824168

4
  • @M66B Last I downgraded another app because it was crashing on my device. This question is not app specific. I'm actually asking how to downgrade any app to it's previous version having already downloaded the apk.
    – SebMa
    Mar 24 '20 at 16:44
  • @SebMa the answer was intended to be generic, but I was not sure if the question was general, hence the link to the FairEmail forum
    – M66B
    Mar 24 '20 at 17:39
  • I understand the risk. Although I'm not sure developers bother update their data structures every now and then, otherwise they will have to rewrite their I/O components often.
    – SebMa
    Mar 25 '20 at 1:01
  • @SebMa especially when using Android ROOM it is easy to add new fields for new features to an existing database, so this might happen more than you think.
    – M66B
    Mar 25 '20 at 7:39
2

If your device is rooted, there's a work-around (apply at your own risk – as Marcel correctly pointed out, there's a reason why it's made close to impossible):

  1. install
  2. backup the app you want to downgrade
  3. uninstall the app you want to downgrade (completely, i.e. app & data)
  4. install the older version
  5. use Titanium Backup to restore data only

This worked for me in several cases. No guarantees however: if the newer version changed structures in its databases/configuration, you will end up with an unstable app – and later updates might fail (in those cases, use TiBu to restore the full backup you made originally – so make sure to keep that one safe).

3
  • The pb. is that my device is not rooted. I've read about this, have you tried it ?
    – SebMa
    Mar 25 '20 at 0:59
  • 1
    Also *migration mode * in settings may be needed to ensure DB integrity
    – beeshyams
    Mar 25 '20 at 7:31
  • 1
    @SebMa Yes, I have – and am quite happy with it. TiBu works fine on Magisk (to my experience on multiple devices, you can safely ignore TiBu's warning concerning SuperUser in that configuration).
    – Izzy
    Mar 25 '20 at 7:41

This site is temporarily in read only mode and not accepting new answers.

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