android通过JNI调用多个.h文件,求高手解答
我的配置是eclipse-cpp-indigo-SR1-incubation-win32(集成c/c++),android-ndk-r8,java文件是TiredCheckJNI.java 具体如下:
package drive.namespace;;
public class TiredCheckJNI {
public native int Initialize();
public native void Uninitialize();
public native void SetFaceDetectParameters(int sensibility);
public native int DetectFaces(byte[] picdata);
public native String test();
}
jni文件夹下.h文件为
com_aheadsoft_drivetired_jni_TiredCheckJNI.h具体内容为:
#include <jni.h>
/* Header for class com_aheadsoft_drivetired_jni_TiredCheckJNI */
#ifndef _Included_com_aheadsoft_drivetired_jni_TiredCheckJNI
#define _Included_com_aheadsoft_drivetired_jni_TiredCheckJNI
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT jint JNICALL Java_com_aheadsoft_drivetired_jni_TiredCheckJNI_Initialize(JNIEnv *, jobject);
JNIEXPORT void JNICALL Java_com_aheadsoft_drivetired_jni_TiredCheckJNI_Uninitialize(JNIEnv *, jobject);
JNIEXPORT void JNICALL Java_com_aheadsoft_drivetired_jni_TiredCheckJNI_SetFaceDetectParameters(JNIEnv *,jobject, jint);
JNIEXPORT jint JNICALL Java_com_aheadsoft_drivetired_jni_TiredCheckJNI_DetectFaces(JNIEnv *, jobject, jbyteArray);
JNIEXPORT jstring JNICALL Java_com_aheadsoft_drivetired_jni_TiredCheckJNI_test(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif
libs文件夹下动态库为:libdsis.so(已经封装好的)
疑问:1.为什么.h文件中的JNIEXPORT jint在eclipse中显示Syntax error;
2.我要在emulator中运行,可是TiredCheckJNI.java 是java形式的,怎么变成android形式的,
3.是不是我的TiredCheckJNI.java 有问题,请帮忙给出src下能在emulator中运行完整代码,最好请留下QQ,好请教,不胜感激!
--------------------编程问答-------------------- 1,这个头文件你无须管的 是通过命令自动生成的
2,不懂你说的什么意思?是不是想说如何运行android项目?建议看看marst老师的视频;
3,同2 --------------------编程问答-------------------- 更正一下:
我的配置是eclipse-cpp-indigo-SR1-incubation-win32(集成c/c++),android-ndk-r8,
java文件是TiredCheckJNI.java 具体如下:
package drive.namespace;;
public class TiredCheckJNI {
static {
System.loadLibrary("dsis");/*加载JNI库*/}
public native int Initialize();
public native void Uninitialize();
public native void SetFaceDetectParameters(int sensibility);
public native int DetectFaces(byte[] picdata);
public native String test();
}
jni文件夹下.h文件为
com_aheadsoft_drivetired_jni_TiredCheckJNI.h具体内容为:
#include <jni.h>
/* Header for class com_aheadsoft_drivetired_jni_TiredCheckJNI */
#ifndef _Included_com_aheadsoft_drivetired_jni_TiredCheckJNI
#define _Included_com_aheadsoft_drivetired_jni_TiredCheckJNI
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT jint JNICALL Java_com_aheadsoft_drivetired_jni_TiredCheckJNI_Initialize(JNIEnv *, jobject);
JNIEXPORT void JNICALL Java_com_aheadsoft_drivetired_jni_TiredCheckJNI_Uninitialize(JNIEnv *, jobject);
JNIEXPORT void JNICALL Java_com_aheadsoft_drivetired_jni_TiredCheckJNI_SetFaceDetectParameters(JNIEnv *,jobject, jint);
JNIEXPORT jint JNICALL Java_com_aheadsoft_drivetired_jni_TiredCheckJNI_DetectFaces(JNIEnv *, jobject, jbyteArray);
JNIEXPORT jstring JNICALL Java_com_aheadsoft_drivetired_jni_TiredCheckJNI_test(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif
我的android主文件是:
import android.graphics.Color;
import android.widget.TextView;
import android.os.Bundle;
public class DriveActivity extends Activity {
/** Called when the activity is first created. */
TiredCheckJNI tiredCheckJNI;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView initialize = (TextView)findViewById(R.id.textView1);
TextView detectFaces = (TextView)findViewById(R.id.textView2);
TextView test= (TextView)findViewById(R.id.textView3);
tiredCheckJNI = new TiredCheckJNI();
tiredCheckJNI.Initialize();
tiredCheckJNI.Uninitialize();
tiredCheckJNI.SetFaceDetectParameters(2);
tiredCheckJNI.DetectFaces(null);
tiredCheckJNI.test();
initialize.setText(tiredCheckJNI.Initialize());
detectFaces.setText(tiredCheckJNI.DetectFaces(null));
test.setText(tiredCheckJNI.test());
libs文件夹下动态库为:libdsis.so(已经封装好的)
疑问:1.为什么.h文件中的JNIEXPORT jint在eclipse中显示Syntax error;
2.我要在emulator中运行,显示the application Drive has stopped unexpectedly,
3.请大侠帮忙修改一下代码,看看哪里错了,最好请留下QQ,好请教,不胜感激!
--------------------编程问答-------------------- 1,显示Syntax error 是Eclipse对语法检查问题,不过不影响你的使用;
2,自己跟一下吧,这里给信息太少,看不出来错在哪里 --------------------编程问答-------------------- 你qq是多少啊? --------------------编程问答-------------------- 你QQ是多少啊?
补充:移动开发 , Android