jni开发中遇到的问题2:Type 'JNIEnv' could not be resolved/Type 'jobject' could not be resolved等等

1:先说下demo的大概过程吧

a:首先呢,配置环境

jni开发中遇到的问题2:Type 'JNIEnv' could not be resolved/Type 'jobject' could not be resolved等等

b:项目添加本地支持

项目---->右键------->AndroidTools----->add native...

c:在MainActivity里面写个本地方法

jni开发中遇到的问题2:Type 'JNIEnv' could not be resolved/Type 'jobject' could not be resolved等等

使用javah命令生成对应的c代码

jni开发中遇到的问题2:Type 'JNIEnv' could not be resolved/Type 'jobject' could not be resolved等等


2:报错的处理(在生成的.h文件里面)

jni开发中遇到的问题2:Type 'JNIEnv' could not be resolved/Type 'jobject' could not be resolved等等

a:首先是#include<jni.h>找不到.h的文件

我的解决方法是:

jni开发中遇到的问题2:Type 'JNIEnv' could not be resolved/Type 'jobject' could not be resolved等等



b:Unable to launch cygpath. Is Cygwin on the path?] java.io.IOException: Cannot run program "cygpath": CreateProcess error=2, 系统找不到指定的文件。

jni开发中遇到的问题2:Type 'JNIEnv' could not be resolved/Type 'jobject' could not be resolved等等

对于这个的处理我是选择忽略,没影响


c:Type 'JNIEnv' could not be resolved/Type 'jobject' could not be resolved

经过a步骤之后,一般就不会在报错了,如果还报错的话,可以尝试删掉之前生成的.h文件,重新使用javah命令生成对应的.h文件