Observed this very strange behavior with Android application. Approximate scenario:
Additional info:
I guess I've got two questions:
Edit (more information):
/data/app/com.myapp-2/base.apk
, /data/app/com.myapp-3/base.apk
, etc.My current hypothesis is that battery drain causes the tablet to "reset" its state (for example, the clock is also reset), and when it's powered again it confuses between app's APKs and loads the wrong one.
However, I have no clue why would it do that, or how to prevent this behavior.
Option 1: Freeze Apps Open “Settings” > “Applications” > “Application Manager“. Choose the app you wish to freeze. Select “Turn off” or “Disable“.
In general, there's no such thing as closing applications in Android: the user just stops using the app. It's up to the programmer to make sure that the user does not mention process creation and termination.
In order to enable a rollback, all you need to do is add the –enable-rollback option to the 'pm install' command when updating an app.
If you are using Android Studio 3.5+, then instead of instant run, you are likely using Apply Changes.
This has a different way of shipping changes to the device, without rewriting the apk, so make a lot of sense that after rebooting, the apk that you will run if you execute your app directly on the device, has nothing to do with the one that was running before
Apply Changes
Instant Run and re-architectured and implemented from the ground-up a more practical approach in Android Studio 3.5 called Apply Changes. Apply Changes uses platform-specific APIs from Android Oreo and higher to ensure reliable and consistent behavior; unlike Instant Run, Apply Changes does not modify your APK.
https://android-developers.googleblog.com/2019/08/android-studio-35-project-marble-goes.html
This lists user installed packages:
adb shell cmd package help
pm list packages -f -U -3 --show-versioncode
And then fully uninstall before reinstalling:
adb uninstall com.myapp
With instant run and not applying the patch APK (see the pm
help output), this might run the base APK. This does not roll-back anything, but it's likely the one APK without the other one APK overloaded (Android Studio might automate the application of the hot-patch, but at boot time this might not be the case). Not using instant run removes these patch update APK; and when there is only one APK, there is nothing else to run.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With