Android Resources$NotFoundException: Unable to find resource ID

1.6k Views Asked by At

I got a report from Firebase of an Activity failing to inflate because it couldn't find one of my resources. I'm really confused about why it couldn't be found, because I believe all the files are in the right directories and the user is using Android v8.1 which isn't ancient and should be able to handle something which I think has been in Android since v1.

Here are the last few stacks of the Exception chain:

Caused by android.content.res.Resources$NotFoundException: File res/drawable/button_close_24dp.xml from drawable resource ID #0x7f08006d
       at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:820)
       at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:630)
       at android.content.res.Resources.getDrawableForDensity(Resources.java:877)
       at ...

Caused by android.content.res.Resources$NotFoundException: Drawable (missing name) with resource ID #0x7f08006e


Caused by android.content.res.Resources$NotFoundException: Unable to find resource ID #0x7f08006e
       at android.content.res.ResourcesImpl.getResourceName(ResourcesImpl.java:253)
       at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:760)
       at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:630)
       at ...

I think that it is complaining that res/drawable/button_close_24dp.xml is missing or cannot be found. I've verified that res/drawable/button_close_24dp.xml does exist in the project (and it loads for the thousands of other users that we have). That xml file is just a simple selector file:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:state_pressed="true" android:drawable="@drawable/button_close_grey_24dp" />
    <item android:drawable="@drawable/button_close_white_24dp" />
</selector>

@drawable/button_close_grey_24dp has two possible versions:

  • /res/drawable/button_close_grey_24dp.png
  • /res/drawable-nodpi/button_close_grey_24dp.xml

The nodpi file is a vector drawable that contains this:

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="24"
    android:viewportHeight="24">
  <path
      android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"
      android:fillColor="#ffffff"/>
</vector>

The Firebase crash report says the user is running Android 8.1.0 on a LGE Nexus 5X. Vector drawables are supposed to be supported starting with Android 5, but even if this user's phone didn't support them for some reason, there is a simple png available to use.

So, I'm really confused why this isn't working universally. I don't want to just close this crash because it only happened to one user... at least not without doing some due diligence by asking y'all. :)

0

There are 0 best solutions below