刚弄android 遇这问题,一上午都没搞定,希望有经验的坛友帮忙看看java层有哪里出错了。
先贴出代码,log在后面。
//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
// 设置渲染对象,用于控制在GLSurfaceView中的绘制工作
setRenderer(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)指的是这里
}
空指针?; 求助;
------解决方案--------------------
MyOpenGL没初始化啊,所以报空指针异常
OpenGLJniLib MyOpenGL = new OpenGLJniLib();
------解决方案--------------------
没有找到libVideoDemo.so这个库,把这个库push到system/lib目录下,或者放到你源码的libs目录下
------解决方案--------------------
Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1311]: 66 cannot locate '_Z7IsEmptyP5Queue'...
把so库放到项目里面libs/armeabi/xx.so