(Android jni) error: base operand of '->' has non-pointer type '_JNIEnv'
来源:互联网 发布:java获取apk版本号 编辑:程序博客网 时间:2024/06/06 01:13
Android将“.c”后缀名改为“.cpp”时java调用native失败及“error: base operand of '->' has non-pointer type '_JNIEnv'
现象:“.c”后缀名改为“.cpp”时java调用native失败 。
解决: 加入“ extern "C" ”。
现象:“error: base operand of '->' has non-pointer type '_JNIEnv'”错误。
解决: 将“(*env)->NewStringUTF(env, "HelloWorld from JNI !");”改为“env->NewStringUTF("HelloWorld from JNI !")”。
例子:
- #include <stdio.h>
- #include <string.h>
- #include <android/log.h>
- #include <jni.h>
- #ifdef __cplusplus
- extern "C"
- {
- #endif
- jint Java_com_duicky_MainActivity_add(JNIEnv* env, jobject thiz, jint x, jint y)
- {
- //该方法为打印的方法
- __android_log_print(ANDROID_LOG_INFO, "JNIMsg", "Get Param: x=%d y=%d ", x, y);
- int iRet = x + y;
- return iRet;
- }
- jstring Java_com_duicky_MainActivity_getString(JNIEnv* env, jobject thiz)
- {
- jstring strRet = env->NewStringUTF("HelloWorld from JNI !");
- return strRet;
- }
- #ifdef __cplusplus
- }
- #endif
- (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'
- JNI: error: base operand of ‘->’ has non-pointer type ‘JNIEnv’
- 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’
- [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
- error: ‘asm’ operand has impossible constraints
- error C2678: binary '>>' : no operator found which takes a left-hand operand of type 'std::
- error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::wstring'
- error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::string'
- error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::string'
- error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::wstring'
- error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class Stude
- error: cannot pass objects of non-trivially-copyable type
- AIX 6.1 参数配置分析和建议-关闭影响性能的系统程序
- 第12部份:新建和退出
- lsof
- Leveldb源码分析--19
- 编译时如果发现无法打开或无法找到 .exe 文件 编译相对路径的设置
- (Android jni) error: base operand of '->' has non-pointer type '_JNIEnv'
- extjs LoadMask 失效 无效 遮罩 问题
- 关联,聚合,组合
- Silverlight 在C#代码中设置Background的值
- DSS Architecture
- java HashMap 按值排序
- GridCtrl 的使用
- HADOOP简介
- ^[0-9]+(\.[0-9]{1,4})?$"); 正则表达式,该表达式的意思:检测字符串是否匹配由0-9出现1次或多次