三星Galaxy S6 / 7/8 - RuntimeException / throwIfCannotDraw

时间:2017-07-12 18:43:32

标签: android imageview

最近随着Android 7.0.0加速,设备随之而来,我的应用程序开始抛出异常而没有特别的原因。问题是我不知道可能是什么问题 - 我所知道的是,它只发生在三星设备上的Nougat及其绘制一些ImageViews。像Admob或Universal-Image-Loader这样的库可以这样做吗?

无论如何这里是完整的例外 - 希望some1可以帮助我...

java.lang.RuntimeException: 
  at android.view.DisplayListCanvas.throwIfCannotDraw(DisplayListCanvas.java:260)
  at android.graphics.Canvas.drawBitmap(Canvas.java:1420)
  at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:545)
  at android.widget.ImageView.onDraw(ImageView.java:1286)
  at android.view.View.draw(View.java:18313)
  at android.view.View.updateDisplayListIfDirty(View.java:17291)
  at android.view.View.draw(View.java:18075)
  at android.view.ViewGroup.drawChild(ViewGroup.java:3966)
  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3752)
  at android.view.View.updateDisplayListIfDirty(View.java:17286)
  at android.view.View.draw(View.java:18075)
  at android.view.ViewGroup.drawChild(ViewGroup.java:3966)
  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3752)
  at android.view.View.draw(View.java:18316)
  at android.view.View.updateDisplayListIfDirty(View.java:17291)
  at android.view.View.draw(View.java:18075)
  at android.view.ViewGroup.drawChild(ViewGroup.java:3966)
  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3752)
  at android.view.View.updateDisplayListIfDirty(View.java:17286)
  at android.view.View.draw(View.java:18075)
  at android.view.ViewGroup.drawChild(ViewGroup.java:3966)
  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3752)
  at android.view.View.updateDisplayListIfDirty(View.java:17286)
  at android.view.View.draw(View.java:18075)
  at android.view.ViewGroup.drawChild(ViewGroup.java:3966)
  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3752)
  at android.view.View.draw(View.java:18316)
  at com.android.internal.policy.DecorView.draw(DecorView.java:850)
  at android.view.View.updateDisplayListIfDirty(View.java:17291)
  at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:666)
  at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:672)
  at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:780)
  at android.view.ViewRootImpl.draw(ViewRootImpl.java:3103)
  at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2899)
  at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2493)
  at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1493)
  at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7040)
  at android.view.Choreographer$CallbackRecord.run(Choreographer.java:927)
  at android.view.Choreographer.doCallbacks(Choreographer.java:702)
  at android.view.Choreographer.doFrame(Choreographer.java:638)
  at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:913)
  at android.os.Handler.handleCallback(Handler.java:751)
  at android.os.Handler.dispatchMessage(Handler.java:95)
  at android.os.Looper.loop(Looper.java:154)
  at android.app.ActivityThread.main(ActivityThread.java:6688)
  at java.lang.reflect.Method.invoke(Native Method:0)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)

2 个答案:

答案 0 :(得分:0)

您可以检查一下位图在被绘制之前是否被回收了吗?

答案 1 :(得分:0)

使用大位图作为TextView的背景时出现此错误。 简单地减少Drawable主文件夹中位图的大小就解决了这个问题。 我想通过将不同分辨率的位图放在多个Drawable文件夹中可以更优雅地解决这个问题