Tuesday, February 18, 2014

Newcomers help! Nullpointerexception problem!


posts by kstg312476 edited 2013-11-14 12:20:18
Just get android encounter this problem, one morning did not get, I hope altar experienced java layer Friends help us to see what went wrong.

First posted code, log in below.

/ / VideoDemo.java--------------------------------------------- -----------------------------
public class VideoDemo extends Activity {
VView vv;
TextView text;
/ / --------------
private MyGLSurfaceView mGLSurfaceView;

@ Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);

/ / ----------------
mGLSurfaceView = new MyGLSurfaceView (this);

setContentView (mGLSurfaceView);
/ / -----------------
}
}
class MyGLSurfaceView extends GLSurfaceView {

public MyGLSurfaceView (Context context) {
super (context);
setEGLContextClientVersion (2); / / This is the important line
/ / Set the render target for controlling the drawing work
GLSurfaceViewsetRenderer (new GL20Renderer ());
}
}

/ / GL20Renderer.java--------------------------------------------- -----------------------------
public class GL20Renderer implements GLSurfaceView.Renderer {

OpenGLJniLib MyOpenGL;

@ Override
public void onSurfaceCreated (GL10 gl, EGLConfig config) {
/ / TODO Auto-generated method stub
MyOpenGL.GlCreate ();

}

@ Override
public void onSurfaceChanged (GL10 gl, int width, int height) {
/ / TODO Auto-generated method stub
MyOpenGL.GlInit ();
}

@ Override
public void onDrawFrame (GL10 gl) {
/ / TODO Auto-generated method stub
MyOpenGL.GlStep ();
}

}

/ / OpenGLJniLib.java--------------------------------------------- -----------------------------
public class OpenGLJniLib {

static {
System.loadLibrary ("VideoDemo");
}

public static native void init ();

public static native void create ();

public static native void step ();

public void GlCreate () {
create ();
}

public void GlInit () {
init ();
}

public void GlStep () {
step ();
}

}

01-01 12:23:44.046: E / AndroidRuntime (4444): FATAL EXCEPTION: GLThread 11
01-01 12:23:44.046: E / AndroidRuntime (4444): java.lang.NullPointerException
01-01 12:23:44.046: E / AndroidRuntime (4444): at com.video.demo.GL20Renderer.onSurfaceCreated (GL20Renderer.java: 14)
01-01 12:23:44.046: E / AndroidRuntime (4444): at android.opengl.GLSurfaceView $ GLThread.guardedRun (GLSurfaceView.java: 1348)
01-01 12:23:44.046: E / AndroidRuntime (4444): at android.opengl.GLSurfaceView $ GLThread.run (GLSurfaceView.java: 1118)


public void onSurfaceCreated (GL10 gl, EGLConfig config) {
/ / TODO Auto-generated method stub
MyOpenGL.GlCreate (); / / (GL20Renderer.java: 14) refers here

}
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
MyOpenGL not initialize ah, so the reported null pointer exception
 OpenGLJniLib MyOpenGL = new OpenGLJniLib (); 

Reply:
cited a floor tantahe reply:
MyOpenGL not initialize ah, so the reported null pointer exception
 OpenGLJniLib MyOpenGL = new OpenGLJniLib (); 


OpenGLJniLib MyOpenGL = new OpenGLJniLib (); / / (GL20Renderer.java: 9) refers here

Thanks Daniel, I turn over. But will prompt new error, really difficult for beginners.

/ / Log ----------------------------------------------- ---------------------
01-01 12:02:45.910: E / AndroidRuntime (1187): FATAL EXCEPTION: main
01-01 12:02:45.910: E / AndroidRuntime (1187): java.lang.ExceptionInInitializerError
01-01 12:02:45.910: E / AndroidRuntime (1187): at com.video.demo.GL20Renderer . (GL20Renderer.java: 9)
01-01 12:02:45.910: E / AndroidRuntime (1187): at com.video.demo.MyGLSurfaceView (VideoDemo.java: 47).
01-01 12:02:45.910: E / AndroidRuntime (1187): at com.video.demo.VideoDemo.onCreate (VedioDemo.java: 25)
01-01 12:02:45.910: E / AndroidRuntime (1187): at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java: 1047)
01-01 12:02:45.910: E / AndroidRuntime (1187): at android.app.ActivityThread.performLaunchActivity (ActivityThread.java: 1586)
01-01 12:02:45.910: E / AndroidRuntime (1187): at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java: 1638)
01-01 12:02:45.910: E / AndroidRuntime (1187): at android.app.ActivityThread.access $ 1500 (ActivityThread.java: 117)
01-01 12:02:45.910: E / AndroidRuntime (1187): at android.app.ActivityThread $ H.handleMessage (ActivityThread.java: 928)
01-01 12:02:45.910: E / AndroidRuntime (1187): at android.os.Handler.dispatchMessage (Handler.java: 99)
01-01 12:02:45.910: E / AndroidRuntime (1187): at android.os.Looper.loop (Looper.java: 123)
01-01 12:02:45.910: E / AndroidRuntime (1187): at android.app.ActivityThread.main (ActivityThread.java: 3647)
01-01 12:02:45.910: E / AndroidRuntime (1187): at java.lang.reflect.Method.invokeNative (Native Method)
01-01 12:02:45.910: E / AndroidRuntime (1187): at java.lang.reflect.Method.invoke (Method.java: 507)
01-01 12:02:45.910: E / AndroidRuntime (1187): at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java: 839)
01-01 12:02:45.910: E / AndroidRuntime (1187): at com.android.internal.os.ZygoteInit.main (ZygoteInit.java: 597)
01-01 12:02:45.910: E / AndroidRuntime (1187): at dalvik.system.NativeStart.main (Native Method)
01-01 12:02:45.910: E / AndroidRuntime (1187): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library [1311]: 66 cannot locate '_Z7IsEmptyP5Queue' ...
01-01 12:02:45.910: E / AndroidRuntime (1187): at java.lang.Runtime.loadLibrary (Runtime.java: 434)
01-01 12:02:45.910: E / AndroidRuntime (1187): at java.lang.System.loadLibrary (System.java: 554)
01-01 12:02:45.910: E / AndroidRuntime (1187): at com.video.demo.OpenGLJniLib . (OpenGLJniLib.java: 6)
01-01 12:02:45.910: E / AndroidRuntime (1187): ... 16 more

Reply:
LibVideoDemo.so did not find the library, the library push to the system / lib directory, or put under your source libs directory
Reply:
Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library [1311]: 66 cannot locate '_Z7IsEmptyP5Queue' ...

The library into the project so there libs / armeabi / xx.so
Reply:
reference to the third floor tantahe reply:
did not find libVideoDemo.so the library, the library push to the system / lib directory, or into your source code Under libs directory


references, 4th Floor lieri111 reply:
Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library [1311]: 66 cannot locate '_Z7IsEmptyP5Queue'. ..

The library into the project so there libs / armeabi / xx.so



so the library has been armeabi under. Although I do not know what went wrong, but again get the next jni, problem solved.

No comments:

Post a Comment