JNI AllocObject called with pending exception java.lang.NoSuchMethodError: no non-static method z

时间:2024-05-22 13:20:49

art/runtime/java_vm_ext.cc:410] JNI DETECTED ERROR IN APPLICATION: JNI AllocObject called with pending

exception java.lang.NoSuchMethodError: no non-static method

"Lcom/niubashaoye/ndk/jni/CCallJavaTools;.add(II)I"

 

错误描述:

通过反射在java的com.niubashaoye.ndk.jni.CCallJavaTools类没有 int add(int,int)函数;

错误原因:

方法不错在,方法名不对、参数个数或类型不对、返回参数不对;

解决方案:

                修改com.niubashaoye.ndk.jni.CCallJavaTools中的方法与C/C++函数调用冲的函数一致就可以了;

 

 

Eg:

1. C/C++函数调用处:调用函数add有两个int类型参数,并返回int类型

JNI AllocObject called with pending exception java.lang.NoSuchMethodError: no non-static method z

 

 2. Java类中的函数:函数参数个数、类型和返回值类型都正确,但是函数名不对,修改一致就可以了

JNI AllocObject called with pending exception java.lang.NoSuchMethodError: no non-static method z