问题
I am using a native library and having the exception below even though the method exists. I have a nativeInit function that is also exported to MapController and it works as expected. However, the nativeLoadScene method causes an error.
JNI DETECTED ERROR IN APPLICATION: jmethodID was NULL
in call to CallObjectMethodV
from int com.demo.lib.MyController.nativeLoadScene(long, java.lang.String, java.lang.String[])
JNI methods
JNIEXPORT jint JNICALL Java_com_demo_lib_MyController_nativeInit(JNIEnv *jniEnv, jobject obj, jobject tangramInstance, jobject assetManager) {
...
}
JNIEXPORT jint JNICALL Java_com_demo_lib_MyController_nativeLoadScene(JNIEnv* jniEnv, jobject obj, jlong mapPtr, jstring path, jobjectArray updateStrings) {
...
}
com.demo.lib.MyController.kt
companion object {
init {
System.loadLibrary("c++_shared")
}
}
// this works
external fun nativeInit(instance: MapController, assetManager: AssetManager?): Long
// this gives error
external fun nativeLoadScene(mapPtr: Long, path: String, updateStrings: Array<String?>?): Int
来源:https://stackoverflow.com/questions/48269981/jmethodid-was-null-for-a-method-with-kotlin