Android - Resources$NotFoundException
Asked Answered
C

3

6

I have an App with over 100.000 Users. But on some devices (~50) I get a strange exception. The stack traces says, that there is an drawable not found.
Here is the stack trace:

java.lang.RuntimeException: Unable to start activity ComponentInfo{mindmApp.the.big.bang.theory.quiz/mindmApp.the.big.bang.theory.quiz.GameNormalActivity}: android.view.InflateException: Binary XML file line #237: Error inflating class 
...
Caused by: android.view.InflateException: Binary XML file line #237: Error inflating class 
at android.view.LayoutInflater.createView(LayoutInflater.java:606)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
...
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:586)
... 28 more
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/textviewxml_joker.xml from drawable resource ID #0x7f02003d
at android.content.res.Resources.loadDrawable(Resources.java:1956)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.view.View.(View.java:2841)
at android.widget.TextView.(TextView.java:580)
at android.widget.TextView.(TextView.java:573)

I have no idea why this drawable (it's a xml-file) is not found.
The binary XML file line #237 is:

<TextView
                    android:id="@+id/textViewSkip"
                    android:layout_width="0px"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="4dp"
                    android:layout_weight="1"
                    android:background="@drawable/textviewxml_joker"
                    android:gravity="center"
                    android:text="@string/tvSkip"
                    android:textAppearance="?android:attr/textAppearanceMedium"
                    android:textColor="@color/color_textview"
                    android:textSize="22sp" />

And here is the textviewxml_joker.xml file:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
    android:drawable="@drawable/textview_joker_pressed"
    android:state_pressed="true"/>
<item android:drawable="@drawable/textview_joker"/>
</selector>

Have anybody an idea t osolve this problem?

Best Regards!

Comeaux answered 27/10, 2012 at 18:40 Comment(4)
Is this textviewxml_joker.xml file exist in drawable folder?Iodoform
Yes, textviewxml_joker.xml file is the the drawable folder.Comeaux
Hi @Namenlos, i am facing a similar issue.. any luck with this? please share.Irmgardirmina
No sorry, I haven't found a solution.Comeaux
W
1

If your textviewxml_joker.xml file isn't in drawable, but rather in a drawable-* folder, then those few devices that get the error may not meet the conditions to use the drawable-* folder.

Put it in drawable as well and it should fix it.

Way answered 27/10, 2012 at 18:51 Comment(1)
No, the textviewxml_joker.xml file is in the normal drawable folder.Comeaux
S
1

This could also happen if the resource you are referring to (lets call it ResA) is in-turn referring to a resource which is missing (lets call it ResB). Android will raise the ResourceNotFoundException for ResA even though whats really missing is ResB. Such is life!

In my case, ResB was defined in the values-swxxxdp but not in values. Hence I was getting this exception on phones but not on tablets.

Subulate answered 15/4, 2014 at 9:8 Comment(0)
N
0

If you have multiple resource folders, make sure that Android finds your drawable xml for every possible qualifier combination (Providing Resources). Looking at the device types that have this error might give you a hint where to look.

Nolie answered 27/10, 2012 at 18:52 Comment(1)
The file is in the normal drawbable folder. All devices must find it there, or not?Comeaux

© 2022 - 2024 — McMap. All rights reserved.