How to downgrade packages in Android Enterprise?

Solved
IS
Ian Stuart
Cross Country Couriers

Hello,

I am having problems downgrading packages successfully in Android Enterprise. I cannot find any SOTI documentation on how to downgrade properly, only upgrade. If someone can please help me with this or point me in the direction of proper documentation I'd appreciate it.

Specifics of my issue are as follows:

  • Android 8.1
  • Zebra TC56
  • SOTI Version 14.4.1.1195 
  • Agent version: 14.4.7.1084
  • Package installed via Android APK in SOTI Package Manager

We have apps that have new versions roughly once a month. So for example I have an app with an April version I needed to roll back to February version. I can upgrade no problem, simply take the new APK, create package with higher version, upload, update in profile and done.

However downgrading, I would THINK I should be able to simply select a lower version of the app in the profile and assign it. This results in an File IO error with no specifics. I then tried taking the older APK (since I keep archives) and repackaging it with a higher package version number, and this failed as well. The odd thing is if I force package reinstall, it works. But this action can only be done per device and we have 1000+ devices.

I have also tried weirder things like syncing the apk as a file with a rule, then trying to run commands manually to install it. I've tried including a pre-install script in my package to remove any newer or older versions before installing, and this failed.

Any help would be greatly appreciated. Thanks!

4 years ago
Android
ANSWERS
MD
Matt Dermody Diamond Contributor
4 years ago

The issue is that Android, at an OS level, doesn't really support the downgrading of an APK to an older version. To work around this, I typically put a pre-install script in all of my APK Packages that first uninstalls and prior versions of the APK. This uninstall script is unnecessary in the upgrade scenarios but comes in really handy in supporting downgrades. This isnt a perfect solution however as completely uninstalling an app will also wipe out its storage which means any cached settings or other usages of app storage will be wiped out. If your app is using a scoped storage directory for configuration settings or other files, this too will get wiped out by the uninstall process. 

You could also send a one time uninstall script to all of the devices that you need to downgrade instead of building it into the packages. Or you could try to move the devices across groups where the old Package is no longer assigned at all to try to have it fully removed before then assigning the downgraded version. 

Solution
IS
Ian Stuart
4 years ago

Matt,

Thanks for the response. This makes sense, and in this case I don't care if the cache is wiped out by a clean install.

I did try the pre-install script in a package with the older APK, but this did not seem to work. File IO error as before. Do you know why that might be? If I send the uninstall script separately, and wait a while, then push the older version that does work but requires a much longer maintenance window for 24/7 devices.

Not a bad idea with the moving to different OU. Would having the options to "not uninstall with profile revocation" cause any issues with this process?

Thank you!

RC
Raymond Chan Diamond Contributor
4 years ago

Most Android device firmwares of different OEM brands only support in-place app upgrade, which means that downgrading require uninstallation of the app and thus wil result in loss of app data (e.g. preferences, cache, etc.) stored in the app file container.  The only exception some years ago were Samsung devices enrolled with Samsung ELM legacy Android+ device agents, and in-place app downgrade was as easy as app upgrade.

IS
Ian Stuart
4 years ago

I found a suitable workaround:

-Create a package with the older APK

-Include preinstall script like so:

uninstall appname

wait 30

-Then the newer apk is uninstalled and after a brief pause the older one is installed. For some reason without this "wait" section the package always errors out for me. I guess SOTI is too fast?

So going forward I will have this script in all our packages which should allow easy downgrading through SOTI's versioning system.