Oreo:android.content.res.Resources $ NotFoundException

时间:2018-02-20 07:02:38

标签: java android android-drawable android-resources android-8.0-oreo

我的应用似乎在Google Play上有一些针对某些Android 8.0设备的错误

不幸的是,到目前为止我还没能自己复制这个bug。

以下是错误日志:

STRDIR + "theirfilename.txt"

所以它在我的onBindViewHoler中是 android.content.res.Resources $ NotFoundException

这是我的代码

android.content.res.Resources$NotFoundException: 
  at android.content.res.ResourcesImpl.getValueForDensity (ResourcesImpl.java:204)
  at android.content.res.Resources.getDrawableForDensity (Resources.java:875)
  at android.content.res.Resources.getDrawable (Resources.java:818)
  at android.content.res.Resources.getDrawable (Resources.java:793)
  at com.aresproductions.booksummaries.fragments.RecyclerViewAdapterBook.onBindViewHolder (RecyclerViewAdapterBook.java:188)
  at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder (RecyclerView.java:6508)
  at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder (RecyclerView.java:6541)
  at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline (RecyclerView.java:5484)
  at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline (RecyclerView.java:5750)
  at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition (RecyclerView.java:5589)
  at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition (RecyclerView.java:5585)
  at android.support.v7.widget.LinearLayoutManager$LayoutState.next (LinearLayoutManager.java:2231)
  at android.support.v7.widget.LinearLayoutManager.layoutChunk (LinearLayoutManager.java:1558)
  at android.support.v7.widget.LinearLayoutManager.fill (LinearLayoutManager.java:1518)
  at android.support.v7.widget.LinearLayoutManager.onLayoutChildren (LinearLayoutManager.java:610)
  at android.support.v7.widget.RecyclerView.dispatchLayoutStep2 (RecyclerView.java:3719)
  at android.support.v7.widget.RecyclerView.dispatchLayout (RecyclerView.java:3436)
  at android.support.v7.widget.RecyclerView.onLayout (RecyclerView.java:3988)
  at android.view.View.layout (View.java:19692)
  at android.view.ViewGroup.layout (ViewGroup.java:6057)
  at android.support.v4.view.ViewPager.onLayout (ViewPager.java:1769)
  at android.view.View.layout (View.java:19692)
  at android.view.ViewGroup.layout (ViewGroup.java:6057)
  at android.support.design.widget.HeaderScrollingViewBehavior.layoutChild (HeaderScrollingViewBehavior.java:132)
  at android.support.design.widget.ViewOffsetBehavior.onLayoutChild (ViewOffsetBehavior.java:42)
  at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onLayoutChild (AppBarLayout.java:1361)
  at android.support.design.widget.CoordinatorLayout.onLayout (CoordinatorLayout.java:874)
  at android.view.View.layout (View.java:19692)
  at android.view.ViewGroup.layout (ViewGroup.java:6057)
  at android.support.v4.widget.DrawerLayout.onLayout (DrawerLayout.java:1172)
  at android.view.View.layout (View.java:19692)
  at android.view.ViewGroup.layout (ViewGroup.java:6057)
  at android.widget.FrameLayout.layoutChildren (FrameLayout.java:323)
  at android.widget.FrameLayout.onLayout (FrameLayout.java:261)
  at android.view.View.layout (View.java:19692)
  at android.view.ViewGroup.layout (ViewGroup.java:6057)
  at android.widget.LinearLayout.setChildFrame (LinearLayout.java:1791)
  at android.widget.LinearLayout.layoutVertical (LinearLayout.java:1635)
  at android.widget.LinearLayout.onLayout (LinearLayout.java:1544)
  at android.view.View.layout (View.java:19692)
  at android.view.ViewGroup.layout (ViewGroup.java:6057)
  at android.widget.FrameLayout.layoutChildren (FrameLayout.java:323)
  at android.widget.FrameLayout.onLayout (FrameLayout.java:261)
  at android.view.View.layout (View.java:19692)
  at android.view.ViewGroup.layout (ViewGroup.java:6057)
  at android.widget.LinearLayout.setChildFrame (LinearLayout.java:1791)
  at android.widget.LinearLayout.layoutVertical (LinearLayout.java:1635)
  at android.widget.LinearLayout.onLayout (LinearLayout.java:1544)
  at android.view.View.layout (View.java:19692)
  at android.view.ViewGroup.layout (ViewGroup.java:6057)
  at android.widget.FrameLayout.layoutChildren (FrameLayout.java:323)
  at android.widget.FrameLayout.onLayout (FrameLayout.java:261)
  at com.android.internal.policy.DecorView.onLayout (DecorView.java:759)
  at android.view.View.layout (View.java:19692)
  at android.view.ViewGroup.layout (ViewGroup.java:6057)
  at android.view.ViewRootImpl.performLayout (ViewRootImpl.java:2515)
  at android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:2224)
  at android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:1410)
  at android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:6834)
  at android.view.Choreographer$CallbackRecord.run (Choreographer.java:1039)
  at android.view.Choreographer.doCallbacks (Choreographer.java:851)
  at android.view.Choreographer.doFrame (Choreographer.java:742)
  at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:1025)
  at android.os.Handler.handleCallback (Handler.java:789)
  at android.os.Handler.dispatchMessage (Handler.java:98)
  at android.os.Looper.loop (Looper.java:164)
  at android.app.ActivityThread.main (ActivityThread.java:6809)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:240)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:767)

我的书籍封面图片包含在drawable-nodpi文件夹中。 再次提醒您,这只发生在某些Android 8.0设备上。

谢谢

1 个答案:

答案 0 :(得分:0)

我遇到同样的错误,但只有从Google Play下载时,从Android Studio本地下载的apk才能正常工作。

11-28 17:13:16.271 788-7441/? I/ActivityManager: START u10 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=au.com.forward.pfodAppDemo/.pfodAppDemo bnds=[297,434][579,758] (has extras)} from uid 1010035
11-28 17:13:16.294 788-913/? W/WindowManager: Token{153434f ActivityRecord{731b9ae u10 au.com.forward.pfodAppDemo/.pfodAppDemo t1000970}} failed creating starting window
    android.content.res.Resources$NotFoundException: Resource ID #0x7f080074
        at android.content.res.ResourcesImpl.getValueForDensity(ResourcesImpl.java:224)
        at android.content.res.Resources.getDrawableForDensity(Resources.java:876)
        at android.content.res.Resources.getDrawable(Resources.java:819)
        at android.content.Context.getDrawable(Context.java:605)
        at com.android.internal.widget.ToolbarWidgetWrapper.setIcon(ToolbarWidgetWrapper.java:322)
        at com.android.internal.widget.ActionBarOverlayLayout.setIcon(ActionBarOverlayLayout.java:742)
        at com.android.internal.policy.PhoneWindow.installDecor(PhoneWindow.java:2685)
        at com.android.internal.policy.PhoneWindow.getDecorView(PhoneWindow.java:2067)
        at com.android.server.policy.PhoneWindowManager.addSplashScreen(PhoneWindowManager.java:2965)
        at com.android.server.wm.SplashScreenStartingData.createStartingSurface(SplashScreenStartingData.java:55)
        at com.android.server.wm.AppWindowContainerController.lambda$-com_android_server_wm_AppWindowContainerController_4735(AppWindowContainerController.java:145)
        at com.android.server.wm.-$Lambda$aEpJ2RCAIjecjyIIYTv6ricEwh4.$m$4(Unknown Source:4)
        at com.android.server.wm.-$Lambda$aEpJ2RCAIjecjyIIYTv6ricEwh4.run(Unknown Source:27)
        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.os.HandlerThread.run(HandlerThread.java:65)
        at com.android.server.ServiceThread.run(ServiceThread.java:46)

更新-2018年11月30日

我有3个具有相同基本代码的应用。但是当从Google Play下载此应用时,它缺少其图标(上面的错误恰好是资源ID)

现在其他两个应用程序都具有用于所有屏幕密度的图标,而此应用程序仅指定了3种密度,可绘制,drawable_hdpi和drawable_mdpi。 即正确下载的其他应用程序均具有适用于所有密度的图标,上述3种以及xhdpi,xxhdpi和xxxhdpi的额外图标。

也许Google的新资源剥离程序正在删除图标的密度与Android 8 Nexus 3不符,但未保留默认图标的图标。

等待Google Play对此问题进行回复。