码迷,mamicode.com
首页 > 其他好文 > 详细

错误: operand of ‘->‘ has non-pointer type ‘JNIEnv

时间:2015-08-20 19:17:55      阅读:320      评论:0      收藏:0      [点我收藏+]

标签:

编译JNI的错误日志:

D:\TVMao\WorkSpace\DramaApp\TestJni>ndk-build
Android NDK: WARNING: APP_PLATFORM android-19 is larger than android:minSdkVersi
on 14 in ./AndroidManifest.xml
[armeabi] Compile++ thumb: test <= test.cpp
jni/test.cpp: In function ‘void Java_com_example_testjni_Decoder_sendIr(JNIEnv*,
 jclass, jint, jintArray)‘:
jni/test.cpp:27:20: error: base operand of ‘->‘ has non-pointer type ‘JNIEnv {ak
a _JNIEnv}‘
jni/test.cpp:28:28: error: base operand of ‘->‘ has non-pointer type ‘JNIEnv {ak
a _JNIEnv}‘
jni/test.cpp:47:8: error: base operand of ‘->‘ has non-pointer type ‘JNIEnv {aka
 _JNIEnv}‘
make.exe: *** [obj/local/armeabi/objs/test/test.o] Error 1

原因是

你代码中使用的C风格访问Env 而 你的文件是 cpp


test.cpp

jsize len = (*env)->GetArrayLength(env, pattern);


(*env)->ReleaseIntArrayElements(env, pattern, patternArray, JNI_ABORT);

 

解决方案

1.改成test.c

2.改成

int* patternArray = env->GetIntArrayElements(pattern, NULL);


   env->ReleaseIntArrayElements(pattern, patternArray, JNI_ABORT);





错误: operand of ‘->‘ has non-pointer type ‘JNIEnv

标签:

原文地址:http://my.oschina.net/sfshine/blog/495146

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!