gpt4 book ai didi

android glsurfaceview空指针异常

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:50:38 26 4
gpt4 key购买 nike

我遇到了这个错误。有什么想法吗?

12-29 22:24:46.087: WARN/dalvikvm(2307): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307): FATAL EXCEPTION: main
12-29 22:24:46.147: ERROR/AndroidRuntime(2307): java.lang.NullPointerException
12-29 22:24:46.147: ERROR/AndroidRuntime(2307): at android.opengl.GLSurfaceView.surfaceCreated(GLSurfaceView.java:471)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307): at android.view.SurfaceView.updateWindow(SurfaceView.java:532)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307): at android.view.SurfaceView.dispatchDraw(SurfaceView.java:339)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307): at android.view.ViewGroup.drawChild(ViewGroup.java:1638)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307): at android.view.View.draw(View.java:6743)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307): at android.widget.FrameLayout.draw(FrameLayout.java:352)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307): at android.view.ViewGroup.drawChild(ViewGroup.java:1640)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307): at android.view.ViewGroup.drawChild(ViewGroup.java:1638)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307): at android.view.View.draw(View.java:6743)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307): at android.widget.FrameLayout.draw(FrameLayout.java:352)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1842)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307): at android.view.ViewRoot.draw(ViewRoot.java:1407)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307): at android.view.ViewRoot.performTraversals(ViewRoot.java:1163)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307): at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307): at android.os.Handler.dispatchMessage(Handler.java:99)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307): at android.os.Looper.loop(Looper.java:123)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307): at android.app.ActivityThread.main(ActivityThread.java:4627)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307): at java.lang.reflect.Method.invokeNative(Native Method)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307): at java.lang.reflect.Method.invoke(Method.java:521)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-29 22:24:46.147: ERROR/AndroidRuntime(2307): at dalvik.system.NativeStart.main(Native Method)
12-29 22:24:46.167: WARN/ActivityManager(57): Force finishing activity com.kamil.cakir/.ResimEgici
12-29 22:24:46.667: WARN/ActivityManager(57): Activity pause timeout for HistoryRecord{43fc5250 com.kamil.cakir/.ResimEgici}

最佳答案

我找到了解决方案。我有一个实现 Renderer 接口(interface)的 GLSurfaceView 类。我忘了将渲染器设置到我的 glview 中。

class CustomGl extends GLSurfaceView implements Renderer{

SquareImage image;
Context context;
float rquad = 0.0f;
public CustomGl(Context context) {
// TODO Auto-generated constructor stub
super(context, null);


//Set this as Renderer
this.setRenderer(this); //**I ADDED THIS THE PROBLEM SOLVED!**


this.context = context;
this.image = new SquareImage();
Log.d(VIEW_LOG_TAG, "gl const");
}

关于android glsurfaceview空指针异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4558435/

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