JNI文件:
jObj = lJNIEnv->NewObjectArray(2,lJNIEnv->FindClass("java/lang/String"),0);
jmethodID APIHttp = lJNIEnv->GetMethodID(lClassDeviceAPI, "PassData","(Ljava/lang/Object;)I");
if(APIHttp == NULL) {
LOGI("CallMethod:: method found");
}
sent=lJNIEnv->CallIntMethod(appc->lObjDeviceAPI,jObj);
Java:
public int PassData(Object object) {
...
..
}
Logs: "CallMethod:: method found"
当我们从JNI =>传递对象时,是否有人知道对象参数需要通过什么?爪哇?
例外:
JNI DETECTED ERROR IN APPLICATION: JNI CallIntMethodV called with pending exception 'java.lang.NoSuchMethodError' thrown in unknown throw location
答案 0 :(得分:0)
如jni.h所示,CallIntMethod具有此签名(将varargs用于其余参数):
jint CallIntMethod(jobject obj, jmethodID methodID, ...)
因此,您的方法ID是第二个参数,而数组在varargs列表中。我假设appc-> lObjDeviceAPI是您的类实例的工作对象。
sent = lJNIEnv->CallIntMethod(appc->lObjDeviceAPI, APIHttp, jObj);