jni遇到invalid conversion from ‘unsigned char*’ to 'const jbyte* {aka const signed char*}'错误
不支持格式之间的转换
错误的栗子:EEP_Buffer C++中的数组
uint8_t i;
FixDirectFunc(Type, PulseWidth, Data, KeyNum); //C中的函数
jbyteArray iarr = env->NewByteArray(188);
env->SetByteArrayRegion(iarr,0,188,EEP_Buffer);
return iarr;
正确的栗子:
uint8_t i;
jbyte res[188];
FixDirectFunc(Type, PulseWidth, Data, KeyNum);
for(i=0;i<188;i++){
res[i] = EEP_Buffer[i];
}
jbyteArray iarr = env->NewByteArray(188);
env->SetByteArrayRegion(iarr,0,188,res);
return iarr;