Search code examples
javaandroidc++android-ndkandroid-5.0-lollipop

Return type of CallStaticBooleanMethodV does not match Java method signature - Calling Java method from C/C++


My java method signature is -

public static void JRequestRender()

And in C/C++

void RequestRender()
{
    ...........
    ...........
    jclass cls = env->GetObjectClass(g_JNIWrapperObj);
    jmethodID mid = NULL;
    if(cls) {
        mid = env->GetStaticMethodID(cls, "JRequestRender", "()V");
    }
    if(mid)
        env->CallStaticBooleanMethod(cls, mid);
    env->DeleteLocalRef(cls);
    .....................
}

This is working in all version of Android except Lollipop. The error log for Lollipop is:

art/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: the return type of CallStaticBooleanMethodV does not match void com.foo.bar.MyJniWrapper.JRequestRender()
..........................................
.............................................

Solution

  • JRequestRender returns void, not bool. You need to use CallStaticVoidMethod.