title: How are we supposed to handle Android App Bundle Resources$NotFoundException crashes due to Offline p2p installs?
body: <p>With Android App Bundles, devices that install the app from the Play Store only receive the resources they need.</p>
  <p>At the same time, Google is also moving forward with their Offline p2p app sharing using &quot;ShareIt&quot; and &quot;Files Go by Google&quot; apps. <a href="https://android-developers.googleblog.com/2018/10/offline-p2p-installs-beta.html" rel="nofollow noreferrer">https://android-developers.googleblog.com/2018/10/offline-p2p-installs-beta.html</a></p>
  <p>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.</p>
  <p>After searching for a solution, I found only answers from a Google Play developer which is:</p>
  <blockquote>
  <p>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.</p>
  <p><a href="https://stackoverflow.com/questions/50471888/android-app-bundle-introduces-resource-not-found-crash-in-android-app/53082301">Android App Bundle introduces Resource Not found crash in Android app</a></p>
  <p><a href="https://stackoverflow.com/questions/52469914/app-sometimes-crashes-with-resourcesnotfoundexception-after-switching-to-androi/52474885">App sometimes crashes with Resources$NotFoundException after switching to android app bundle distribution</a></p>
  </blockquote>
  <p>In the meanwhile our Play Console crash statistics are rising closer and closer to the &quot;Bad Behaviour Threshold&quot; 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.</p>
  <p>The only workaround to avoid this which we can think of right now is to either:</p>
  <ul>
  <li>Upon app startup, check that the packageManager.getInstallerPackageName for the app is &quot;com.android.vending&quot; 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.</li>
  </ul>
  <p>OR</p>
  <ul>
  <li>Revert back to using apks instead of app bundles.</li>
  </ul>
  <p>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.</p>
  <p>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?</p>