Reputation: 3406
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.
Android App Bundle introduces Resource Not found crash in Android app
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:
OR
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?
Upvotes: 3
Views: 1243
Reputation: 583
You have to check it manually that application is getting installed by play-store or side-load. The PackageManager class supplies the getInstallerPackageName() method that will tell you the package name of whatever installed the package you specify. Side-loaded apps will not contain a value. For reference please check this out. This crash will occurred only once i.e. first time.
Upvotes: 0
Reputation: 13842
You should be able to filter crash reports on the source "Installed From Play" or "Installed From anywhere" in the Play console. If the apps weren't installed from Play then it shouldn't affect your Vitals rating for Bad behaviour threshold.
If the apps were installed from Play then the ResourceNotFound exception should not be happening. If you have ResourceNotFound happening crashes when only viewing apps installed from Play then it is a bug.
Please report it to the Play Console Developer Support using the help (question mark) icon in the Play Console
Upvotes: 2