cannot initialize a parameter of type 'jboolean *' (aka 'unsigned char *') with an rva


cannot initialize a parameter of type ‘jboolean ‘ (aka ‘unsigned char ‘) with an rva

AndroidStudio升级到最新3.4.1, Gradle5.1.1,NDK Cmake3.6.4

编译运行项目报错

cannot initialize a parameter of type ‘jboolean ‘ (aka ‘unsigned char ‘) with an rvalue of type ‘bool’

错误源码:

1
2
3
4
5
const char *jstringTocharArray(JNIEnv *env, jstring str) {
return env->GetStringUTFChars(str,false);

}
const char* GetStringUTFChars(jstring string, jboolean* isCopy)

原因:

新版的jni规范更加严格,需要使用内置的bool属性常量,改成JNI_FALSE之后这个错误消失了。

修改后源码:即可

1
char16 *fixed_ptr = (char16*)(*env).GetStringChars(fixed_str, JNI_FALSE);