gpt4 book ai didi

android - android.view.GLES20RecordingCanvas 中的 NullPointerException

转载 作者:行者123 更新时间:2023-11-30 03:25:12 27 4
gpt4 key购买 nike

我在 android.view.GLES20RecordingCanvas.drawPatch() 中看到 NullPointerException 崩溃报告

安卓源码在这里http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.0.1_r1/android/view/GLES20RecordingCanvas.java

似乎仅在 4.0.x 的第 97 行崩溃,当 Activity 启用硬件加速时。

堆栈跟踪:

java.lang.NullPointerException
at android.view.GLES20RecordingCanvas.drawPatch(GLES20RecordingCanvas.java:97)
at android.graphics.NinePatch.draw(NinePatch.java:125)
at android.graphics.drawable.NinePatchDrawable.draw(NinePatchDrawable.java:189)
at android.widget.ScrollBarDrawable.drawThumb(ScrollBarDrawable.java:178)
at android.widget.ScrollBarDrawable.draw(ScrollBarDrawable.java:137)
at android.view.View.onDrawVerticalScrollBar(View.java:9532)
at android.view.View.onDrawScrollBars(View.java:9476)
at android.view.View.draw(View.java:11091)
at android.widget.AbsListView.draw(AbsListView.java:3428)
at android.view.View.getDisplayList(View.java:10455)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2605)
at android.view.View.getDisplayList(View.java:10418)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2605)
at android.view.View.getDisplayList(View.java:10418)
at android.view.ViewGroup.drawChild(ViewGroup.java:2858)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2497)
at android.view.View.draw(View.java:11067)
at android.view.View.getDisplayList(View.java:10455)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2605)
at android.view.View.getDisplayList(View.java:10418)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2605)
at android.view.View.getDisplayList(View.java:10418)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2605)
at android.view.View.getDisplayList(View.java:10418)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2605)
at android.view.View.getDisplayList(View.java:10418)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2605)
at android.view.View.getDisplayList(View.java:10418)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2605)
at android.view.View.getDisplayList(View.java:10418)
at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:879)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:1955)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1661)
at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2505)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:4945)
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)

是否有解决此问题的简单方法,或者我是否需要为受影响的 Activity 关闭硬件加速?

最佳答案

有一种方法可以解决这个问题。归结为禁用硬件加速:

  • 对于有问题的 View ,使用 myView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
  • 对于特定的操作系统版本(例如,所有早于 JB MR1 的版本),使用 these tricks .

this question 中找到的信息来源.

关于android - android.view.GLES20RecordingCanvas 中的 NullPointerException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18340296/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com