NullPointerException GLES20RecordingCanvas.drawBitmap 4.0.3& 4.0.4

时间:2014-06-05 11:02:53

标签: android performance

我在Play商店看到了我的应用程序的崩溃报告,我不知道这个问题。我想明白,如果我使用" hardwareAccelerated false" ,这是有用的方法吗?或者这个问题的原因是什么?我怎么解决这个问题。有4.0.3和4.0.4的设备遇到了这次崩溃

崩溃日志:https://gist.github.com/semihozkoroglu/30be3fda7257d002e2fe

java.lang.NullPointerException
at android.view.GLES20RecordingCanvas.drawBitmap(GLES20RecordingCanvas.java:118)
at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:393)
at android.view.View.draw(View.java:10968)
at android.view.ViewGroup.drawChild(ViewGroup.java:2887)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
at com.slidingmenu.lib.CustomViewAbove.dispatchDraw(CustomViewAbove.java:1067)
at android.view.View.draw(View.java:10986)
at android.view.View.getDisplayList(View.java:10422)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2597)
at android.view.View.getDisplayList(View.java:10385)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2597)
at android.view.View.getDisplayList(View.java:10385)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2597)
at android.view.View.getDisplayList(View.java:10385)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2597)
at android.view.View.getDisplayList(View.java:10385)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2597)
at android.view.View.getDisplayList(View.java:10385)
at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:849)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:1910)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1634)
at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2442)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)

谢谢。

2 个答案:

答案 0 :(得分:0)

我相信你可以通过使用drawBitmap方法之一解决这个问题,这些方法接受你要渲染的源图像的矩形作为参数。这是Android的几个特定版本中的一个错误,其中将整个图像绘制到画布的默认行为不起作用。

假设您想要绘制整个位图,您的代码可能如下所示:

canvas.drawBitmap(bitmap, new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()), bitmapPosition, paint);

答案 1 :(得分:0)

如果您使用动画,也许您可​​以尝试将“删除视图”发布到UI线程? 我遇到了和你一样的堆栈。但我认为这是根本原因。

How to remove a View when animation ends?