Java层与Jni层的字节数组传递

JNIEXPORT jbyteArray JNICALL Java_com_zl_lowevel_ZigBeeNative_getJniString
(JNIEnv *env, jobject thiz)
{
LOGD("-------------%s----------", FUNCTION);

jint ret;
jint i;
char data_buf[128];

if((ret = read(fd_zigbee, data_buf, strlen(data_buf))) < 0){
    LOGE("read error");
}

jbyteArray array = env->NewByteArray(ret);
env->SetByteArrayRegion(array, 0, ret, data_buf);

return array;
//将ascii字符串转换成unicode编码方式
//return env->NewStringUTF("dddd");

}

In file included from jni/zigBee_jni.cpp:1:0:
F:/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/jni.h:592:13: note: the mangling of 'va_list' has changed in GCC 4.4
jni/zigBee_jni.cpp: In function '_jbyteArray* Java_com_zl_lowevel_ZigBeeNative_getJniString(JNIEnv*, jobject)':
jni/zigBee_jni.cpp:91:49: error: invalid conversion from 'char*' to 'const jbyte* {aka signed char const*}' [-fpermissive]
F:/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/jni.h:967:10: error: initializing argument 4 of 'void _JNIEnv::SetByteArrayRegion(jbyteArray, jsize, jsize, const jbyte*)' [-fpermissive]
make: *** [obj/local/armeabi/objs/zigBee_jni/zigBee_jni.o] Error 1

求技术大牛解决下,项目救急

jni

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐