android 资源$NotFoundException -资源ID #< address>

brvekthn  于 2023-05-12  发布在  Android
关注(0)|答案(1)|浏览(126)

我面临着很多关于Resoures$NotFoundException与许多不同设备的问题。我无法在我的三星A50(Android v11,One UI v3. 1)和Nexus 5(Android v6. 0. 1)设备上复制这个问题。在我使用App Bundle后,这个问题每天都会出现,甚至返回上传为APK文件也有同样的问题。所以我不知道是什么原因导致app崩溃。
下面是跟踪报告

Fatal Exception: android.view.InflateException: Binary XML file line #39: Binary XML file line #39: Error inflating class ImageButton

Caused by android.view.InflateException: Binary XML file line #39: Error inflating class ImageButton

Caused by android.content.res.Resources$NotFoundException: Drawable (missing name) with resource ID #0x7f0800ad

Caused by android.content.res.Resources$NotFoundException: Unable to find resource ID #0x7f0800ad
       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 android.content.res.Resources.loadDrawable(Resources.java:886)
       at android.content.res.TypedArray.getDrawableForDensity(TypedArray.java:953)
       at android.content.res.TypedArray.getDrawable(TypedArray.java:928)
       at android.content.res.XResources$XTypedArray.getDrawable(XResources.java:1363)
       at android.widget.ImageView.<init>(ImageView.java:188)
       at android.widget.ImageButton.<init>(ImageButton.java:86)
       at android.widget.ImageButton.<init>(ImageButton.java:82)
       at androidx.appcompat.widget.AppCompatImageButton.<init>(AppCompatImageButton.java:3)
       at androidx.appcompat.widget.AppCompatImageButton.<init>(AppCompatImageButton.java:3)
       at androidx.appcompat.app.AppCompatViewInflater.createImageButton(AppCompatViewInflater.java:15)
       at androidx.appcompat.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:15)
       at androidx.appcompat.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:15)
       at androidx.appcompat.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:15)
       at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:189)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:772)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
       at com.pn.namewallpaper.databinding.BsFontColorStyleBinding.bind(BsFontColorStyleBinding.java:4)
       at com.pn.namewallpaper.databinding.BsFontColorStyleBinding.inflate(BsFontColorStyleBinding.java:4)
       at com.pn.namewallpaper.fragments.FontColorStyle2BSDialog.Q(FontColorStyle2BSDialog.java:6)
       at androidx.fragment.app.Fragment.b0(Fragment.java:20)
       at androidx.fragment.app.DialogFragment.performCreateView(DialogFragment.java)
       at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:223)
       at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:154)
       at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1069)
       at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:91)
       at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:74)
       at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:3)
       at android.os.Handler.handleCallback(Handler.java:790)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6494)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

我的xml布局文件代码如下

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">

<HorizontalScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="10dp">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="5dp"
        android:gravity="center_vertical"
        android:orientation="horizontal">

        <FrameLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="0dp"
            android:layout_marginEnd="10dp"
            android:background="@drawable/rounded_spinner">

            <Spinner
                android:id="@+id/spColorStyle"
                style="@style/spinner"
                android:contentDescription="@string/style" />
        </FrameLayout>

        <ImageButton
            android:id="@+id/btnAngle"
            style="@style/ButtonStyle.Circle"
            android:layout_marginStart="0dp"
            android:layout_marginEnd="10dp"
            android:contentDescription="@string/rotate"
            android:src="@drawable/ic_arrow_angle" />

        <Button
            android:id="@+id/btnRandom"
            style="@style/ButtonStyle.BottomSheet"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="0dp"
            android:layout_marginEnd="10dp"
            android:text="@string/random" />

        <Button
            android:id="@+id/btnSame"
            style="@style/ButtonStyle.BottomSheet"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="0dp"
            android:layout_marginEnd="10dp"
            android:text="@string/same" />

    </LinearLayout>
</HorizontalScrollView>

我附上了Firebase Crashlytics的坠机报告

谢谢,请帮助我如何解决这个问题。

3phpmpom

3phpmpom1#

一些设备不匹配以上目录drawable-hdpi,drawable-mdpi,drawable-xhdpi和drawable-xxhdpi这就是发生崩溃原因。
将默认图片放入drawable目录。如果有任何匹配的,它将从可绘制中获取。应用程序不会崩溃

相关问题