8

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. :)

Kenny Wyland
  • 20,844
  • 26
  • 117
  • 229
  • do you have access to that device? are you able to reproduce the error? something similar happened to me with an emulated device but in my case the error was due to some unnecesary attributes in my vector path. I would tell you to try replacing the drawables to see if it fixes the issue but for that you would need the device – quealegriamasalegre Oct 27 '21 at 00:52
  • @quealegriamasalegre Unfortunately, no, this is a Firebase crash report from one of my users who could be anywhere in the world and they chose not to share their user id (i.e. supposedly personally identifiable info) so I can't even try to contact them directly. I'm sort of working blind. – Kenny Wyland Oct 29 '21 at 04:43
  • 3
    I also got this error from Firebase, and I confirm that the resource exists in my app. And It is also showing the crash that happens on Android 8.1 LGE Nexus 5X. I even purchased an LG Nexus 5X phone with Android 8.0 and I can confirm it does not crash on the device. I did a lot of research and it seems the error could be caused by the APK being downloaded outside of GooglePlay and being manipulated. – Zhang Zhan Nov 08 '21 at 05:50
  • Same for me, only happening on Nexus 5X: Caused by android.content.res.Resources$NotFoundException: File res/drawable/abc_switch_thumb_material.xml from drawable resource ID #0x7f08004b. @KennyWyland Did u managed to fix that issue? – Dziki Arbuz Aug 23 '22 at 08:05
  • Same here. I can't say, it has something to do with the latest update of my app, but until now it happens only with this new production version. So I also get that on Firebase Crashlytics: `Unable to start activity ComponentInfo{de.xroot.wishlist/de.xroot.wishlist.activity.MainActivity}: android.content.res.Resources$NotFoundException: Drawable de.xroot.wishlist:drawable/background_transition with resource ID #0x7f070090`. I also confirm that until now it happens only on Nexus 5X with Android 8.1.0. This is the suspicious part. @Zhang Zhan your sideloading theory sounds plausible. – cybergen Sep 10 '22 at 21:43
  • @Zhang Zhan Coud you try to reproduce it on the Nexus 5X with Android 8.1.0? – cybergen Sep 10 '22 at 21:45
  • This statement suggests, that the theory of @Zhang Zhan could be true and the problem occurs only with the app sideloaded. https://stackoverflow.com/a/52474885/590947 – cybergen Sep 10 '22 at 22:11
  • I am having the same problem with our app. And yes, weirdly, only happens in Nexus 5X running Android 8.1.0 – Talobin Sep 23 '22 at 01:55

0 Answers0