Howto downgrade any app to the previous version without losing data on android oreo? 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 ?
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