base operand of '->' has non-pointer type 'JNIEnv {aka _JNIEnv}'和Method 'GetStringUTFChars' could no
来源:互联网 发布:js input value 赋值 编辑:程序博客网 时间:2024/05/21 21:40
Android NDK带的jni例子都是使用C定义JNI接口,但是在项目中,因为Native代码是用C++编写的,所以我就使用C++定义JNI接口,但是初学者总会遇到很多问题:
jni中的常见问题:
1、base operand of '->' has non-pointer type 'JNIEnv {aka _JNIEnv}'和Method 'GetStringUTFChars' could not be resolved
其中这个问题是跟你jni配置时到底是.cpp还是.c文件及如图所示:
和
解决问题的办法:
1》使用c++来写代码,文件名就必须【cpp】后缀:
C++ code must have .cpp extension.,必须cpp后缀,c后缀不行;
2》使用c来写代码,文件名就必须【c】后缀;
2》调用的代码这么来写:
//return (*env)->NewStringUTF(env, "Hello from JNI !");//如果是用C语言格式就用这种方式
//return env->NewStringUTF((char *)"Hello from JNI !");//C++用这种格式
//return env->NewStringUTF((char *)"Hello from JNI !");//C++用这种格式
错误的办法:
网上有一种方法是如下,但这方方法明显是骗小孩子的,哪有用忽略这种东西的,不推荐正确的办法:
问题是就是上面第二点,因此
这是如果想深究原因可以查看<jni.h>
1、用.cpp文件定义的
const char* GetStringUTFChars(jstring string, jboolean* isCopy)
{ return functions->GetStringUTFChars(this, string, isCopy); }
2、用.c文件定义
const char* (*GetStringUTFChars)(JNIEnv*, jstring, jboolean*);
0 0
- base operand of '->' has non-pointer type 'JNIEnv {aka _JNIEnv}'和Method 'GetStringUTFChars' could no
- base operand of '->' has non-pointer type 'JNIEnv {aka _JNIEnv}'和Method 'GetStringUTFChars' could no
- error: base operand of ‘->’ has non-pointer type ‘JNIEnv’
- JNI: error: base operand of ‘->’ has non-pointer type ‘JNIEnv’
- (Android jni) error: base operand of '->' has non-pointer type '_JNIEnv'
- 安卓JNI编程-- :error: base operand of '->' has non-pointer type '_JNIEnv' 解决办法
- JNI错误之:error: base operand of '->' has non-pointer type '_JNIEnv'
- [Error] base operand of '->' has non-pointer type 'stac
- C++ : 出错解释 base operand of '->' has non-pointer type 'std::pair<int, int>'
- Android将“.c”后缀名改成“.cpp”时java调用native失败及“error: base operand of '->' has non-poin
- cast of Objective-C pointer type 'NSString *' to C pointer type 'CFStringRef' (aka 'const struct __C
- Virtual method and base-type pointer make polymorphism in C++
- Method 'GetStringUTFChars' could not be resolved
- error: cannot pass objects of non-trivially-copyable type ‘std::string {aka class std::basic_string
- Android NDK开发method GetStringUTFChars’could not be resolved
- Android NDK开发method GetStringUTFChars’could not be resolved
- Type 'JNIEnv' could not be resolved
- Error1error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'std::
- GradientDrawable和AttributeSet自定义控件
- iOS中代理属性为什么要用Weak修饰?
- 扫一扫
- Android开发中常犯的错误有哪些
- linux, bsd
- base operand of '->' has non-pointer type 'JNIEnv {aka _JNIEnv}'和Method 'GetStringUTFChars' could no
- MapperScannerConfigurer在mybatis-spring的妙用
- POJ 3080 Blue Jeans【多串最长子串】
- 基于bootstrap table分页数据及行内编辑和导出数据(二)导出数据
- HDU 2870 Largest Submatrix(dp最大子矩阵和)
- Python中re(正则表达式)模块学习
- 使用jquery的ajax需要注意的地方dataType的设置 (目前我也不是很清楚哎)
- Android 中的线程是如何调度
- jQuery隐藏显示