簡體   English   中英

Android-Resources $ NotFoundException

[英]Android - Resources$NotFoundException

我有一個擁有超過100.000用戶的應用程序。 但是在某些設備上(約50個),我得到一個奇怪的異常。 堆棧痕跡表明,沒有找到可繪制對象。
這是堆棧跟蹤:

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)

我不知道為什么找不到此可繪制對象(它是一個xml文件)。
二進制XML文件第237行為:

<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" />

這是textviewxml_joker.xml文件:

<?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>

有沒有人想解決這個問題?

最好的祝福!

如果您的textviewxml_joker.xml文件不在drawable ,而是在drawable-*文件夾中,則少數出現錯誤的設備可能不符合使用drawable-*文件夾的條件。

也將其放在drawable ,並且應該對其進行修復。

如果您要引用的資源(簡稱為ResA)反過來又引用了缺少的資源(簡稱為ResB),也會發生這種情況。 即使ResB真正缺少的是,Android也會為ResA引發ResourceNotFoundFoundException。 這就是生活!

就我而言,ResB是在值-swxxxdp中定義的,但未在值中定義。 因此,我在手機而非平板電腦上遇到了此異常。

如果您有多個資源文件夾,請確保Android為每種可能的限定符組合( 提供資源 )找到可繪制的xml。 查看出現此錯誤的設備類型可能會提示您在哪里查找。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM