I faced a situation in which the version from the built debug APK had inexplicable runtime errors which disappeared after the rebuild. No code changes - just fresh build. Today it happened at least a second time - it starts to worry me.
It's a waste of time to determine that error couldn't be repeated on my emulator and I just need to rebuild it. Here I can only build APKs one by one until I get two files equal to byte. Though I've never faced the same problem while installing directly through USB, it couldn't be a solution as I don't have physical access to it all the time.
Update. Today such a thing happened through USB installation.
The second reason is main here. Can I be sure the release build doesn't have the same problem? Now I build AAB files that I can't install on a device to check before update in Google Play.
Current Android Studio version:
Android Studio Arctic Fox | 2020.3.1 Patch 1 Build
#AI-203.7717.56.2031.7621141, built on August 7, 2021
Update. Repeated on Android Studio version:
Android Studio Arctic Fox | 2020.3.1 Patch 2 Build
#AI-203.7717.56.2031.7678000, built on August 27, 2021
Other build settings
buildToolsVersion '30.0.2'
gradle version 7.0.2
Why does it happen? Is there any workaround?
Patch 2 is available, It seems there are some issue with gradle build. here is the link of the issue tracker. https://issuetracker.google.com/issues/195968520?pli=1
As suggested in issue tracker can you please try with below configs.
The kotlin metadata should be deterministic from version 3.0.69 and forward. You can try out that version by adding the following to your top-level build.gradle file:
Here is the link of all resolved issues for patch 2. https://androidstudio.googleblog.com/2021/09/android-studio-arctic-fox-202031-patch.html