With Android App Bundles, devices that install the app from the Play Store only receive the resources they need.
At the same time, Google is also moving forward with their Offline p2p app sharing using "ShareIt" and "Files Go by Google" apps. https://android-developers.googleblog.com/2018/10/offline-p2p-installs-beta.html
Our app uses a few .png images that has resources for each drawable-dpi from ldpi to xxxhdpi, but even so, we've started receiving a lot of Resources$NotFoundException crashes due to the bundle apk being shared offline to devices requiring different resources.
After searching for a solution, I found only answers from a Google Play developer which is:
I suspect in the long run the websites and P2P sharing programs will get better at sharing such APKs properly, so I wouldn't spend too long worrying about it.
In the meanwhile our Play Console crash statistics are rising closer and closer to the "Bad Behaviour Threshold" due to the slowly rising number of Resources$NotFoundException crashes after we switched to App Bundles. About 1% of our users seem to be sharing the app offline.
The only workaround to avoid this which we can think of right now is to either:
- Upon app startup, check that the packageManager.getInstallerPackageName for the app is "com.android.vending" which means it comes from the Play Store, and redirect them to re-install from the Play Store if it isn't, which ensures the Play Store gives that device the correct bundle resources. However this completely negates the advantage of Offline p2p app sharing.
- Revert back to using apks instead of app bundles.
A third option could be to ensure all image resources are dpi-independent vector drawables but this isn't very realistic as image resources aren't always simple enough to be vector drawables.
Is there a more elegant or recommended way to handle this Resources$NotFoundException issue with Android App Bundles and Offline p2p app sharing, or has anyone come across better workarounds to help prevent them?