jmethodID was NULL for a method with Kotlin

这一生的挚爱 提交于 2019-12-24 06:38:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!