1

I want to use AndroLua as library in my Android application.

Everything goes well on Android version except Android 5.x (Lollipop)

But my app crashed under Lollipop if I call juajava.new lua function. The logcat shows

JNI DETECTED ERROR IN APPLICATION: can't call static int org.keplerproject.luajava.LuaJavaAPI.javaNew(int, java.lang.Class) on class java.lang.Class<java.lang.Class>

How can I solve the problem? Or is there alternative to run lua in Android?

WeiHung
  • 109
  • 2
  • 10
  • I give up the luajava.new function. Instead, create new object in java and return the new created object to lua. – WeiHung Sep 13 '15 at 13:50

1 Answers1

0

https://github.com/jasonsantos/luajava/issues/10 fixes the bug:

Calling luajava.new(...) produce the following error on Android ART: A/art: art/runtime/java_vm_ext.cc:410] JNI DETECTED ERROR IN APPLICATION: can't call static int org.keplerproject.luajava.LuaJavaAPI.javaNew(int, java.lang.Class) with class java.lang.Class A/art: art/runtime/java_vm_ext.cc:410] in call to CallStaticIntMethod

After some code review, I figured out the problem. In luajava.c, line 1377: ret = ( *javaEnv )->CallStaticIntMethod( javaEnv , clazz , method , (jint)stateIndex , classInstance ); "clazz" is not the object we want here. It should be: ret = ( *javaEnv )->CallStaticIntMethod( javaEnv , luajava_api_class , method , (jint)stateIndex , classInstance );

Moreover, I think, line 1371: if ( clazz == NULL || method == NULL ) should be: if ( luajava_api_class == NULL || method == NULL )

Nir.

Vadim Peretokin
  • 2,221
  • 3
  • 29
  • 40