PDA

View Full Version : [Android] Resolution for NullPointerException : onSurfaceCreated(SourceFile:487)



Tibal
15.09.2014, 13:24
Hi,

Implementing Skobbler in my android app, I stucked half an hour with a crash I couldn't understand.
Following the DemoApp for the initialization part, I kept crashing just before map was displayed with error:

java.lang.NullPointerException
at com.skobbler.ngx.map.MapRenderer.onSurfaceCreated( SourceFile:487)
at android.opengl.GLSurfaceView$GLThread.guardedRun(G LSurfaceView.java:1509)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfac eView.java:1248)

As the error wasn't self explanatory at all, I investigated file MapRenderer from package com.skobbler.ngx.map, and found
that I was crashing because I didn't implement a map listener (this.s, in line below), which classname was trying to be displayed on log.


public final void onSurfaceCreated(GL10 arg1, EGLConfig paramEGLConfig)
{
SKLogging.writeLog("MapRenderer", "onSurfaceCreated before LOCK ", 2);
synchronized (V) {
SKLogging.writeLog("MapRenderer", "onSurfaceCreated" + this.s.getClass().getName(), 2); // <== Line 487

You might have forgot to check non-nullity of this.s before logging it, and as it wasn't described as mandatory in your doc to
implement this listener,I think you should correct that, or otherwise precise it in documentation.

I think this answer could be useful for other people.

Thanks for reading.

Adela_Silvia
15.09.2014, 15:00
Hi,

Thank you very much for taking the time to share this with us.
We will make this improvement in our SDK.

We are glad to have such great users in our community!