android glsurfaceview null pointer exception
I got this error. Any idea ?
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/AndroidRun开发者_如何学Gotime(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}
I found the solution. I had a GLSurfaceView class implementing the Renderer interface. I have forgotton to set the renderer into my 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");
}
精彩评论