Hi, I have a problem with LuaState.call native code…
It works but sometimes it crashes the app with the following error:
07-08 15:18:33.482: W/dalvikvm(15714): JNI WARNING: threadid=12 using env from threadid=1
07-08 15:18:33.482: W/dalvikvm(15714): JNI WARNING: JNI method called with exception pending
07-08 15:18:33.482: W/dalvikvm(15714): in Lcom/ansca/corona/JavaToNativeShim;.nativeRender:(J)V (GetIntField)
07-08 15:18:33.482: W/dalvikvm(15714): Pending exception is:
07-08 15:18:33.482: I/dalvikvm(15714): java.lang.Error: bad argument #2 to ‘?’ (number expected, got no value)
07-08 15:18:33.482: I/dalvikvm(15714): at com.ansca.corona.JavaToNativeShim.nativeRender(Native Method)
07-08 15:18:33.482: I/dalvikvm(15714): at com.ansca.corona.JavaToNativeShim.render(JavaToNativeShim.java:185)
07-08 15:18:33.482: I/dalvikvm(15714): at com.ansca.corona.Controller.updateRuntimeState(Controller.java:293)
07-08 15:18:33.482: I/dalvikvm(15714): at com.ansca.corona.graphics.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:417)
07-08 15:18:33.482: I/dalvikvm(15714): at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1622)
07-08 15:18:33.482: I/dalvikvm(15714): at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1377)
07-08 15:18:33.489: A/libc(15714): Fatal signal 11 (SIGSEGV) at 0x64616220 (code=2)
07-08 15:18:33.489: I/dalvikvm(15714): “GLThread 1664” prio=5 tid=12 NATIVE
07-08 15:18:33.489: I/dalvikvm(15714): | group=“main” sCount=0 dsCount=0 obj=0x41308d30 self=0x7ca6f8
07-08 15:18:33.489: I/dalvikvm(15714): | sysTid=15743 nice=0 sched=0/0 cgrp=default handle=7162840
07-08 15:18:33.489: I/dalvikvm(15714): | schedstat=( 54873748791 12140869010 124564 ) utm=4482 stm=1004 core=0
07-08 15:18:33.489: I/dalvikvm(15714): at com.ansca.corona.JavaToNativeShim.nativeRender(Native Method)
07-08 15:18:33.489: I/dalvikvm(15714): at com.ansca.corona.JavaToNativeShim.render(JavaToNativeShim.java:185)
07-08 15:18:33.489: I/dalvikvm(15714): at com.ansca.corona.Controller.updateRuntimeState(Controller.java:293)
07-08 15:18:33.489: I/dalvikvm(15714): at com.ansca.corona.graphics.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:417)
07-08 15:18:33.489: I/dalvikvm(15714): at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1622)
07-08 15:18:33.489: I/dalvikvm(15714): at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1377)
07-08 15:18:33.489: E/dalvikvm(15714): VM aborting
07-08 15:18:33.489: A/libc(15714): Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1)
I’m using an Async Lua function that start a bluetooth discovering and, when It finish, the native environment call Lua … this is a part of my code… please help me
com.ansca.corona.CoronaRuntimeTask task = new com.ansca.corona.CoronaRuntimeTask() {
@Override
public void executeUsing(com.ansca.corona.CoronaRuntime runtime) {
// *** We are now running on the Corona runtime thread. ***
try {
// Fetch the Corona runtime’s Lua state.
com.naef.jnlua.LuaState luaState = runtime.getLuaState();
// Fetch the Lua function stored in the registry and push it to the top of the stack.
luaState.rawGet(com.naef.jnlua.LuaState.REGISTRYINDEX, luaFunctionReferenceKey);
// Remove the Lua function from the registry.
luaState.unref(com.naef.jnlua.LuaState.REGISTRYINDEX, luaFunctionReferenceKey);
mBtAdapter = BluetoothAdapter.getDefaultAdapter();
startScanBT(luaState); //luaState is used to make Call when bluetooth finish.
}
catch (Exception ex) {
ex.printStackTrace();
}
}
};
// Send the above task to the Corona runtime asynchronously.
// The send() method will do nothing if the Corona runtime is no longer available, which can
// happen if the runtime was disposed/destroyed after the user has exited the Corona activity.
dispatcher.send(task);
THE ANDROID VERSION IS 4.0.4 — PLEASE HELP ME