0

I am facing a lot of issue regarding Resoures$NotFoundException with many different device. I am unable to replicate this issue with my Samsung A50 (Android v11, One UI v3.1) and Nexus 5 (Android v6.0.1) devices. After I am using App Bundle this problem raises every day and even return to upload as APK file also have same issue. So I am not sure for which reason app is crashing.

Below is the trace report

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)

My xml layout file code below

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

I have attached crash report from Firebase Crashlytics

Crash Report

Thanks Please help me how can I fix this issue.

Pratik
  • 30,639
  • 18
  • 84
  • 159

2 Answers2

1

some device not matched above directory drawable-hdpi, drawable-mdpi, drawable-xhdpi and drawable-xxhdpi that's what crash happened.

Put default image in the directory drawable. if anything matched it will take from the drawable. App wont crash

sasikumar
  • 12,540
  • 3
  • 28
  • 48
  • the system selects the appropriate bitmap based on the screen's dpi. If you don't provide a density-specific resource for that density, the system locates the next-best match and scales it to fit the screen. – Pratik May 08 '23 at 11:34
  • but your case its not taken next-best match. so that i told put default image in drawable – sasikumar May 08 '23 at 11:50
0

I fixed it, I have drawable vector icon along with png files in drawable-anydpi folder. I deleted all the vectors icon and just provide png icons only. Now no more crash report generated related to this issue.

Pratik
  • 30,639
  • 18
  • 84
  • 159