Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resources.NotFoundException thrown on res/color/secondary_text_dark.xml

Tags:

android

I've received a crash report with an error caused by a Resource.NotFoundException. What is strange, however, is that it is thrown by the Android compatibility library in a DialogFragment when it is trying to use the res/color/secondary_text_dark.xml colour (during its creation). This is an Android resource (found in android.R.color.secondary_text_dark), so I assume that every device should have this available.

I have an idea that the exception is caused because Proguard has obfuscated the resources, but I'm not sure how to avoid this. I am not able to reproduce the crash on my Nexus One, so I will not be able to check if a change fixes this.

Am I right about the obfuscator or are there any other things which could cause this?

Thank you very much.

I've attached the log here:

android.view.InflateException: Binary XML file line #8: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:513)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at org.kaloersoftware.kaloerclock.MathDialogFragment.android.view.View onCreateView(android.view.LayoutInflater,android.view.ViewGroup,android.os.Bundle)(Unknown Source)
at android.support.v4.app.FragmentManagerImpl.void moveToState(android.support.v4.app.Fragment,int,int,int)(Unknown Source)
                                              void moveToState(android.support.v4.app.Fragment)
                                              void moveToState(int,boolean)
                                              void moveToState(int,int,int,boolean)
at android.support.v4.app.FragmentManagerImpl.void moveToState(android.support.v4.app.Fragment,int,int,int)(Unknown Source)
                                              void moveToState(android.support.v4.app.Fragment)
                                              void moveToState(int,boolean)
                                              void moveToState(int,int,int,boolean)
at android.support.v4.app.BackStackRecord.void run()(Unknown Source)
at android.support.v4.app.FragmentManagerImpl.boolean execPendingActions()(Unknown Source)
at android.support.v4.app.FragmentManagerImpl$1.void run()(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4669)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:876)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at android.widget.TextView.<init>(TextView.java:329)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
at android.view.LayoutInflater.createView(LayoutInflater.java:500)
... 20 more
Caused by: android.content.res.Resources$NotFoundException: File res/color/secondary_text_dark.xml from color state list resource ID #0x0
at android.content.res.Resources.loadColorStateList(Resources.java:1817)
at android.content.res.TypedArray.getColorStateList(TypedArray.java:342)
at android.widget.TextView.<init>(TextView.java:394)
... 24 more
Caused by: android.content.res.Resources$NotFoundException: File res/color/secondary_text_dark.xml from xml type colorstatelist resource ID #0x0
at android.content.res.Resources.loadXmlResourceParser(Resources.java:1924)
at android.content.res.Resources.loadColorStateList(Resources.java:1812)
... 26 more

And this is the layout.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:padding="8dip"
    android:background="#33332D"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:textSize="50sp"
        android:gravity="center"
        android:paddingBottom="10dip"
        android:textColor="@color/ltgrey"
        android:id="@+id/math_question_question"
        />
    <TableLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:weightSum="2">
        <TableRow>
            <Button
                android:textSize="30sp"
                android:id="@+id/math_question_ans1"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight="1"/>
            <Button 
                android:textSize="30sp"
                android:id="@+id/math_question_ans2"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight="1"/>
        </TableRow>
        <TableRow>
            <Button
                android:textSize="30sp"
                android:id="@+id/math_question_ans3"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight="1"/>
            <Button
                android:textSize="30sp"
                android:id="@+id/math_question_ans4"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight="1"/>
        </TableRow>
    </TableLayout>
    <Button
        android:textSize="30sp"
        android:id="@+id/math_question_cancel"
        android:text="@string/math_question_cancel"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"/>
</LinearLayout>

The textColor in the first TextView refers to this in my colors.xml file

<color name="ltgrey">#ffe0e0e0</color>
like image 859
Kaloer Avatar asked Nov 04 '22 21:11

Kaloer


1 Answers

it is thrown by the Android compatibility library in a DialogFragment when it is trying to use the res/color/secondary_text_dark.xml colour (during its creation). This is an Android resource (found in android.R.color.secondary_text_dark), so I assume that every device should have this available.

Android is trying to load R.color.secondary_text_dark, not android.R.color.secondary_text_dark, based upon your stack trace.

like image 139
CommonsWare Avatar answered Nov 14 '22 21:11

CommonsWare