奇怪的android.content.res.Resources $ NotFoundException:无法找到资源ID#0x7f06008d

时间:2019-07-15 01:57:12

标签: java android

Crashlytics报告了加载图片时android.content.res.Resources $ NotFoundException多次崩​​溃。 所有崩溃都发生在我在Play商店中发布的应用中。

我在不同的设备上测试了我的应用程序,从api级别23到29,从mdpi到xxhdpi,但无法重现崩溃。

堆栈跟踪

Fatal Exception: android.view.InflateException: Binary XML file line #18: Binary XML file line #18: Error inflating class ImageView

Caused by android.view.InflateException: Binary XML file line #18: Error inflating class ImageView

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

Caused by android.content.res.Resources$NotFoundException: Unable to find resource ID #0x7f06008d
       at android.content.res.ResourcesImpl.getResourceName + 228(ResourcesImpl.java:228)
       at android.content.res.ResourcesImpl.loadDrawableForCookie + 687(ResourcesImpl.java:687)
       at android.content.res.ResourcesImpl.loadDrawable + 571(ResourcesImpl.java:571)
       at android.content.res.Resources.loadDrawable + 858(Resources.java:858)
       at android.content.res.TypedArray.getDrawable + 928(TypedArray.java:928)
       at android.widget.ImageView.(ImageView.java:162)
       at android.widget.ImageView.(ImageView.java:150)
       at androidx.appcompat.widget.AppCompatImageView.()
       at androidx.appcompat.widget.AppCompatImageView.(:20)
       at androidx.appcompat.app.AppCompatViewInflater.createImageView(AppCompatViewInflater.java:20)
       at androidx.appcompat.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:3)
       at android.view.LayoutInflater$FactoryMerger.onCreateView + 192(LayoutInflater.java:192)
       at android.view.LayoutInflater.createViewFromTag + 769(LayoutInflater.java:769)
       at android.view.LayoutInflater.createViewFromTag + 727(LayoutInflater.java:727)
       at android.view.LayoutInflater.rInflate + 858(LayoutInflater.java:858)
       at android.view.LayoutInflater.rInflateChildren + 821(LayoutInflater.java:821)
       at android.view.LayoutInflater.inflate + 518(LayoutInflater.java:518)
       at android.view.LayoutInflater.inflate + 426(LayoutInflater.java:426)
       at com.myapp.util.IntroSlideUtils.onCreateView(IntroSlideUtils.java)
       at androidx.fragment.app.Fragment.performCreateView(Fragment.java)
       at androidx.fragment.app.FragmentManagerImpl.addAddedFragments(FragmentManagerImpl.java:72)
       at androidx.fragment.app.FragmentManagerImpl.burpActive(FragmentManagerImpl.java)
       at androidx.fragment.app.FragmentManagerImpl.addAddedFragments(FragmentManagerImpl.java)
       at androidx.fragment.app.BackStackRecord.detach(BackStackRecord.java)
       at androidx.fragment.app.FragmentManagerImpl.addAddedFragments(FragmentManagerImpl.java:11)
       at androidx.fragment.app.FragmentManagerImpl.dispatchOnFragmentDetached(FragmentManagerImpl.java)
       at androidx.fragment.app.FragmentManagerImpl.execSingleAction(FragmentManagerImpl.java:3)
       at androidx.fragment.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:3)
       at androidx.fragment.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:3)
       at androidx.viewpager.widget.ViewPager.populate(ViewPager.java)
       at androidx.viewpager.widget.ViewPager.populate(ViewPager.java)
       at androidx.viewpager.widget.ViewPager.onMeasure(ViewPager.java)
       at android.view.View.measure + 19857(View.java:19857)
       at android.widget.RelativeLayout.measureChildHorizontal + 715(RelativeLayout.java:715)
       at android.widget.RelativeLayout.onMeasure + 461(RelativeLayout.java:461)
       at android.view.View.measure + 19857(View.java:19857)
       at android.view.ViewGroup.measureChildWithMargins + 6083(ViewGroup.java:6083)
       at android.widget.FrameLayout.onMeasure + 185(FrameLayout.java:185)
       at androidx.appcompat.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java)
       at android.view.View.measure + 19857(View.java:19857)
       at android.view.ViewGroup.measureChildWithMargins + 6083(ViewGroup.java:6083)
       at android.widget.LinearLayout.measureChildBeforeLayout + 1464(LinearLayout.java:1464)
       at android.widget.LinearLayout.measureVertical + 758(LinearLayout.java:758)
       at android.widget.LinearLayout.onMeasure + 640(LinearLayout.java:640)
       at android.view.View.measure + 19857(View.java:19857)
       at android.view.ViewGroup.measureChildWithMargins + 6083(ViewGroup.java:6083)
       at android.widget.FrameLayout.onMeasure + 185(FrameLayout.java:185)
       at android.view.View.measure + 19857(View.java:19857)
       at android.view.ViewGroup.measureChildWithMargins + 6083(ViewGroup.java:6083)
       at android.widget.LinearLayout.measureChildBeforeLayout + 1464(LinearLayout.java:1464)
       at android.widget.LinearLayout.measureVertical + 758(LinearLayout.java:758)
       at android.widget.LinearLayout.onMeasure + 640(LinearLayout.java:640)
       at android.view.View.measure + 19857(View.java:19857)
       at android.view.ViewGroup.measureChildWithMargins + 6083(ViewGroup.java:6083)
       at android.widget.FrameLayout.onMeasure + 185(FrameLayout.java:185)
       at com.android.internal.policy.DecorView.onMeasure + 690(DecorView.java:690)
       at android.view.View.measure + 19857(View.java:19857)
       at android.view.ViewRootImpl.performMeasure + 2275(ViewRootImpl.java:2275)
       at android.view.ViewRootImpl.measureHierarchy + 1366(ViewRootImpl.java:1366)
       at android.view.ViewRootImpl.performTraversals + 1619(ViewRootImpl.java:1619)
       at android.view.ViewRootImpl.doTraversal + 1254(ViewRootImpl.java:1254)
       at android.view.ViewRootImpl$TraversalRunnable.run + 6338(ViewRootImpl.java:6338)
       at android.view.Choreographer$CallbackRecord.run + 874(Choreographer.java:874)
       at android.view.Choreographer.doCallbacks + 686(Choreographer.java:686)
       at android.view.Choreographer.doFrame + 621(Choreographer.java:621)
       at android.view.Choreographer$FrameDisplayEventReceiver.run + 860(Choreographer.java:860)
       at android.os.Handler.handleCallback + 751(Handler.java:751)
       at android.os.Handler.dispatchMessage + 95(Handler.java:95)
       at android.os.Looper.loop + 154(Looper.java:154)
       at android.app.ActivityThread.main + 6121(ActivityThread.java:6121)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run + 889(ZygoteInit.java:889)
       at com.android.internal.os.ZygoteInit.main + 779(ZygoteInit.java:779)

layout.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="match_parent"
    android:gravity="center"
    android:orientation="vertical"
    android:background="@color/primary">

    <TextView
        ....../>

    <ImageView
        android:layout_width="280dp"
        android:layout_height="280dp"
        android:src="@drawable/oasis"/>

    <TextView
        ....../>
</LinearLayout>

可绘制结构 资源ID#0x7f06008d指向oasis.png structure

drawable
--oasis(6)
 ----oasis.png
 ----oasis.png(hdpi)
 ----oasis.png(mdpi)
 ----oasis.png(xhdpi)
 ----oasis.png(xxhdpi)
 ----oasis.png(xxxhdpi)

我不知道为什么会有这个错误。谁能帮我?谢谢!

1 个答案:

答案 0 :(得分:-2)

您应该有七个Drawable文件夹,而不是六个。 ldpi文件夹丢失了,它也就是您的Drawable。