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

App sometimes crashes with Resources$NotFoundException after switching to android app bundle distribution

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.

OR

  • 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?

Answer

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

  • 1
Reply Report
    • Ah I didn't know that non-play install crashes wouldn't affect vitals, good to know! ? The exception doesn't occur from installs from Play, only when those installs are shared. We decided to go with Pierre's suggestion as a compromise until we see their solution is released, as we still want our offline p2p install users to have a usable app.

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.

  • 0
Reply Report

Warm tip !!!

This article is reproduced from Stack Exchange / Stack Overflow, please click

Trending Tags

Related Questions