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!
The ResourceNotFoundException exception is thrown if a security provider looks for a resource that should exist, but is unable to find that resource.
For each type of resource, there is an R subclass (for example, R. drawable for all drawable resources) and for each resource of that type, there is a static integer (for example, R. drawable. icon ). This integer is the resource ID that you can use to retrieve your resource.
Resources/layout folder − It contains all the Android XML files (. axml) that Android uses to build user interfaces. The Resources/values folder − It contains XML files to declare key-value pairs for strings (and other types) throughout an application.
Every app project must have an AndroidManifest. xml file (with precisely that name) at the root of the project source set. The manifest file describes essential information about your app to the Android build tools, the Android operating system, and Google Play.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With