JNI- java.lang.UnsatisfiedLinkError: Native method not found

后端 未结 4 956
自闭症患者
自闭症患者 2020-12-10 05:43

I\'m developing an Android project using OpenCV. Some of the methods do not have Java version, so I have to use NDK to use them in my project.

This is my first time

4条回答
  •  有刺的猬
    2020-12-10 06:29

    I added

    extern "C"
    

    before functions declare ex:

    extern "C"
    jstring
    Java_lara_myapplication_MainActivity_stringFromJNI(
            JNIEnv *env,
        jobject /* this */) {
        std::string hello = "Hello from C++";
        return env->NewStringUTF(hello.c_str());
    }
    

    then the error was gone

提交回复
热议问题