2011-05-18 177 views
0

我崩潰時,我打電話給我的原生功能,在這裏我的Android應用程序是我的代碼:的Android NDK(OpenCV的)

lib libo=new lib(); 
public void onPreviewFrame(byte[] data, Camera camera) 
{ 
    int s;// where w and h are width and height are the parameters of the camera 
    s=libo.getdata(data);/: and getdata is my native function 
}     

我getdata.c:

#include "getdata.h" 
JNIEXPORT int JNICALL JAVA_android_video8_libo_som 
(JNIEnv* env, jobject obj,jbyte* data) 
{ 
    return (data[1]); 
} 

getdata.h:

#include <jni.h> 


#ifndef _Included_android_video8_lib 
#define _Included_android_video8_lib 
#ifdef __cplusplus 
extern "C" { 
#endif 

JNIEXPORT int JNICALL JAVA_android_video8_libo_som(JNIEnv* env, jobject obj, jbyte*); 

#ifdef __cplusplus 
} 
#endif 
#endif 

Android.mk:

LOCAL_PATH := $(call my-dir) 
include $(CLEAR_VARS) 
LOCAL_MODULE := opcv 
LOCAL_SRC_FILES := getdata.c 
include $(BUILD_SHARED_LIBRARY) 

和類在那裏我打電話的lib:

package android.video8; 

public class libo { 
    static { 
     System.loadLibrary("opcv"); 
      } 
     public native static int som(int s); 
} 
沒有問題,但應用程序的執行產生庫

給我一個崩潰 我不沒有地方EHE誤差 感謝

+0

你到底想要完成什麼? – 2011-05-18 08:25:01

回答

1

似乎在你的問題有一些錯誤。無論如何,你正在使用JNI函數的錯誤原型。你應該使用這些簽名:

JNIEXPORT 
jint JNICALL JAVA_android_video8_libo_getData(JNIEnv*, jclass, jbyteArray); 

JNIEXPORT 
jint JNICALL JAVA_android_video8_libo_som(JNIEnv*, jclass, jint); 

並使用JAVAH每次更改本地方法的原型時間工具。