java.lang.RuntimeException:Canvas:尝试使用循环位图android.graphics.Bitmap

时间:2015-07-29 07:40:25

标签: android

嗨,我有这个奇怪的问题。我写这个问题的主要原因是这个异常没有引用我的代码,但它只引用了核心的android库。如何确定哪个位图可以回收并希望使用?它发生在三星galaxy s5上。我也在生成的文件中检查了我整个项目的id 30c3578e,但我什么都没发现。这可以在Android中吗?

java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap@30c3578e 

    --------- Stack trace ---------

        android.graphics.Canvas.throwIfCannotDraw(Canvas.java:1225) 
        android.view.GLES20Canvas.drawBitmap(GLES20Canvas.java:600) 
        android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:543) 
        android.widget.ImageView.onDraw(ImageView.java:1187) 
        android.view.View.draw(View.java:16060) 
        android.view.View.updateDisplayListIfDirty(View.java:14991) 
        android.view.View.getDisplayList(View.java:15014) 
        android.view.View.draw(View.java:15781) 
        android.view.ViewGroup.drawChild(ViewGroup.java:3677) 
        android.view.ViewGroup.dispatchDraw(ViewGroup.java:3471) 
        android.view.View.draw(View.java:16063) 
        android.view.View.updateDisplayListIfDirty(View.java:14991) 
        android.view.View.getDisplayList(View.java:15014) 
        android.view.View.draw(View.java:15781) 
        android.view.ViewGroup.drawChild(ViewGroup.java:3677) 
        android.view.ViewGroup.dispatchDraw(ViewGroup.java:3471) 
        android.view.View.draw(View.java:16063) 
        android.view.View.updateDisplayListIfDirty(View.java:14991) 
        android.view.View.getDisplayList(View.java:15014) 
        android.view.View.draw(View.java:15781) 
        android.view.ViewGroup.drawChild(ViewGroup.java:3677) 
        android.widget.ListView.drawChild(ListView.java:3462) 
        android.view.ViewGroup.dispatchDraw(ViewGroup.java:3471) 
        android.widget.AbsListView.dispatchDraw(AbsListView.java:3103) 
        android.widget.ListView.dispatchDraw(ListView.java:3457) 
        android.view.View.draw(View.java:16063) 
        android.widget.AbsListView.draw(AbsListView.java:5989) 
        android.view.View.updateDisplayListIfDirty(View.java:14991) 
        android.view.View.getDisplayList(View.java:15014) 
        android.view.View.draw(View.java:15781) 
        android.view.ViewGroup.drawChild(ViewGroup.java:3677) 
        android.view.ViewGroup.dispatchDraw(ViewGroup.java:3471) 
        android.view.View.draw(View.java:16063) 
        android.view.View.updateDisplayListIfDirty(View.java:14991) 
        android.view.View.getDisplayList(View.java:15014) 
        android.view.View.draw(View.java:15781) 
        android.view.ViewGroup.drawChild(ViewGroup.java:3677) 
        android.view.ViewGroup.dispatchDraw(ViewGroup.java:3471) 
        android.view.View.draw(View.java:16063) 
        android.view.View.updateDisplayListIfDirty(View.java:14991) 
        android.view.View.getDisplayList(View.java:15014) 
        android.view.View.draw(View.java:15781) 
        android.view.ViewGroup.drawChild(ViewGroup.java:3677) 
        android.view.ViewGroup.dispatchDraw(ViewGroup.java:3471) 
        android.view.View.draw(View.java:16063) 
        android.widget.FrameLayout.draw(FrameLayout.java:592) 
        android.view.View.updateDisplayListIfDirty(View.java:14991) 
        android.view.View.getDisplayList(View.java:15014) 
        android.view.View.draw(View.java:15781) 
        android.view.ViewGroup.drawChild(ViewGroup.java:3677) 
        android.view.ViewGroup.dispatchDraw(ViewGroup.java:3471) 
        android.view.View.draw(View.java:16063) 
        android.support.v4.view.ViewPager.draw(ViewPager.java:2176) 
        android.view.View.updateDisplayListIfDirty(View.java:14991) 
        android.view.View.getDisplayList(View.java:15014) 
        android.view.View.draw(View.java:15781) 
        android.view.ViewGroup.drawChild(ViewGroup.java:3677) 
        android.view.ViewGroup.dispatchDraw(ViewGroup.java:3471) 
        android.view.View.draw(View.java:16063) 
        android.view.View.updateDisplayListIfDirty(View.java:14991) 
        android.view.View.getDisplayList(View.java:15014) 
        android.view.View.draw(View.java:15781) 
        android.view.ViewGroup.drawChild(ViewGroup.java:3677) 
        android.support.v4.widget.DrawerLayout.drawChild(DrawerLayout.java:1060) 
        android.view.ViewGroup.dispatchDraw(ViewGroup.java:3471) 
        android.view.View.draw(View.java:16063) 
        android.view.View.updateDisplayListIfDirty(View.java:14991) 
        android.view.View.getDisplayList(View.java:15014) 
        android.view.View.draw(View.java:15781) 
        android.view.ViewGroup.drawChild(ViewGroup.java:3677) 
        android.view.ViewGroup.dispatchDraw(ViewGroup.java:3471) 
        android.view.View.draw(View.java:16063) 
        android.widget.FrameLayout.draw(FrameLayout.java:592) 
        android.view.View.updateDisplayListIfDirty(View.java:14991) 
        android.view.View.getDisplayList(View.java:15014) 
        android.view.View.draw(View.java:15781) 
        android.view.ViewGroup.drawChild(ViewGroup.java:3677) 
        android.view.ViewGroup.dispatchDraw(ViewGroup.java:3471) 
        android.view.View.draw(View.java:16063) 
        com.android.internal.widget.ActionBarOverlayLayout.draw(ActionBarOverlayLayout.java:501) 
        android.view.View.updateDisplayListIfDirty(View.java:14991) 
        android.view.View.getDisplayList(View.java:15014) 
        android.view.View.draw(View.java:15781) 
        android.view.ViewGroup.drawChild(ViewGroup.java:3677) 
        android.view.ViewGroup.dispatchDraw(ViewGroup.java:3471) 
        android.view.View.draw(View.java:16063) 
        android.widget.FrameLayout.draw(FrameLayout.java:592) 
        com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2916) 
        android.view.View.updateDisplayListIfDirty(View.java:14991) 
        android.view.View.getDisplayList(View.java:15014) 
        android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:275) 
        android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:281) 
        android.view.ThreadedRenderer.draw(ThreadedRenderer.java:320) 
        android.view.ViewRootImpl.draw(ViewRootImpl.java:2741) 
        android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2573) 
        android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2165) 
        android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1180) 
        android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6558) 
        android.view.Choreographer$CallbackRecord.run(Choreographer.java:777) 
        android.view.Choreographer.doCallbacks(Choreographer.java:590) 
        android.view.Choreographer.doFrame(Choreographer.java:560) 
        android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:763) 
        android.os.Handler.handleCallback(Handler.java:739) 
        android.os.Handler.dispatchMessage(Handler.java:95) 
        android.os.Looper.loop(Looper.java:145) 
        android.app.ActivityThread.main(ActivityThread.java:5832) 
        java.lang.reflect.Method.invoke(Native Method) 
        java.lang.reflect.Method.invoke(Method.java:372) 
        com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399) 
        com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194) 

1 个答案:

答案 0 :(得分:1)

首先,如果您希望我们进行调查,您应该提供您的代码。

其次,你可以在之前检查你的位图:

bitmap.isRecycled();
  

如果此位图已被回收,则返回true。如果是这样,那么尝试访问其像素是错误的,并且位图将不会绘制。