解决NDK开发中的 Method 'NewStringUTF' could not be resolved
2016-11-24 16:15
411 查看
写这个代码时报错:pEnv->NewStringUTF(),
仔细一看原来是:因为c和c++对JNIEnv的定义是不同的,从jni.h下面代码看得出来
这么来解决问题:
使用c++来写代码,文件名就必须【cpp】后缀:
C++ code must have .cpp extension.,必须cpp后缀,c后缀不行;
使用c来写代码,文件名就必须【c】后缀;
调用的代码这么来写:
//return (*env)->NewStringUTF(env, “Hello from JNI !”);//如果是用C语言格式就用这种方式
//return env->NewStringUTF((char *)”Hello from JNI !”);//C++用这种格式
仔细一看原来是:因为c和c++对JNIEnv的定义是不同的,从jni.h下面代码看得出来
这么来解决问题:
使用c++来写代码,文件名就必须【cpp】后缀:
C++ code must have .cpp extension.,必须cpp后缀,c后缀不行;
使用c来写代码,文件名就必须【c】后缀;
调用的代码这么来写:
//return (*env)->NewStringUTF(env, “Hello from JNI !”);//如果是用C语言格式就用这种方式
//return env->NewStringUTF((char *)”Hello from JNI !”);//C++用这种格式
相关文章推荐
- 【android】解决NDK开发中的 Method 'NewStringUTF' could not be resolved
- 解决NDK开发中的 Method 'NewStringUTF' could not be resolved
- window平台下 Eclipse Ndk开发中的Method 'NewStringUTF' could not be resolved问题
- window平台下 Eclipse Ndk开发中的Method 'NewStringUTF' could not be resolved问题
- window平台下 Eclipse Ndk开发中的Method 'NewStringUTF' could not be resolved问题
- Eclipse Ndk开发中的Method 'NewStringUTF' could not be resolved问题
- window平台下 Eclipse Ndk开发中的Method 'NewStringUTF' could not be resolved问题
- Method 'NewStringUTF' could not be resolved
- Eclipse - Method NewStringUTF() could not be resolved
- Android: Type Method 'NewStringUTF' could not be resolved
- Eclipse Ndk开发中的Method 'NewStringUTF' could not ...
- Method 'NewStringUTF' could not be resolved
- 【android】NDK开发编译C++文件出现Type 'jint' could not be resolved和Unresolved inclusion: <jni.h>的解决办法
- android NDK开发编译C++文件出现Type 'jint' could not be resolved和Unresolved inclusion: <jni.h>的解决办法
- Android NDK开发method GetStringUTFChars’could not be resolved
- Android NDK开发method GetStringUTFChars’could not be resolved
- Android NDK开发method GetStringUTFChars’could not be resolved
- android NDK开发编译C++文件出现Type 'jint' could not be resolved和Unresolved inclusion: <jni.h>的解决办法
- android NDK开发编译时出现Type 'jint' could not be resolved和Unresolved inclusion: <jni.h>的解决办法
- NDK :Type 'xxx' could not be resolved解决