JNI DETECTED ERROR IN APPLICATION: can't call void com.example.wxy.ndks.Utils.fun3() on instance of

1046 ワード

//cmake  
JNIEXPORT void JNICALL
Java_com_example_wxy_ndks_Utils_funs2(JNIEnv *env, jobject instance, jstring methodName_,
                                      jstring methodSign_) {

    char *methodName = jstringToChar(env, methodName_);//    
    char *methodSign = jstringToChar(env, methodSign_);//    
    //     
    jclass clazz = env->GetObjectClass(instance);
    if (clazz == NULL) {
        return;
    }
    //          jmethodid
    jmethodID motheid = env->GetMethodID(clazz, methodName, methodSign);
    if (motheid == NULL) {
        env->DeleteLocalRef(clazz);
        return;
    }
    //    ID
    jstring data = env->NewStringUTF("hello!");
    if (data == NULL) {
        env->DeleteLocalRef(clazz);
        env->DeleteLocalRef(data);
        return;
    }

    //    
     env->CallVoidMethod(instance, motheid, data)//    
     //env->CallVoidMethod(clazz, motheid, data)
    //    
    env->DeleteLocalRef(clazz);


}c