2016-04-21 66 views
0

有人可以帮助我找到我的错误,我看了看看我看起来似乎找不到它,我试图运行我的代码,但它不断给我提示以下错误:java.lang.UnsatisfiedLinkError: Native method not found: nemo.lungu.receiptor.scanlibrary.ScanActivity.getPoints:(Landroid/graphics/Bitmap;)[F是我的活动方法getPoints()java.lang.UnsatisfiedLinkError:在Android中找不到原生方法

public native float[] getPoints(Bitmap bitmap); 

方法getPoints()的头版本:

JNIEXPORT jfloatArray JNICALL Java_nemo_lungu_receiptor_scanlibrary_ScanActivity_getPoints 
(JNIEnv *, jobject, jobject); 

终于方法getPoints()在我.cpp文件执行:

JNIEXPORT jfloatArray JNICALL Java_nemo_lungu_receiptor_scanlibrary_ScanActivity_getPoints 
(JNIEnv *env, jobject thiz,jobject bitmap) 
{ 
__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "Scaning getPoints"); 
int ret; 
AndroidBitmapInfo info; 
void* pixels = 0; 

if ((ret = AndroidBitmap_getInfo(env, bitmap, &info)) < 0) { 
    __android_log_print(ANDROID_LOG_VERBOSE, APPNAME,"AndroidBitmap_getInfo() failed ! error=%d", ret); 
    return 0; 
} 

if (info.format != ANDROID_BITMAP_FORMAT_RGBA_8888) 
{  __android_log_print(ANDROID_LOG_VERBOSE, APPNAME,"Bitmap format is not RGBA_8888!"); 
    return 0; 
} 

if ((ret = AndroidBitmap_lockPixels(env, bitmap, &pixels)) < 0) { 
    __android_log_print(ANDROID_LOG_VERBOSE, APPNAME,"AndroidBitmap_lockPixels() failed ! error=%d", ret); 
} 

// init our output image 
Mat mbgra(info.height, info.width, CV_8UC4, pixels); 
vector<Point> img_pts = getPoints(mbgra); 

jfloatArray jArray = env->NewFloatArray(8); 

if (jArray != NULL) 
{ 
    jfloat *ptr = env->GetFloatArrayElements(jArray, NULL); 

    for (int i=0,j=i+4; j<8; i++,j++) 
    { 
     ptr[i] = img_pts[i].x; 
     ptr[j] = img_pts[i].y; 
    } 
    env->ReleaseFloatArrayElements(jArray, ptr, NULL); 
} 
AndroidBitmap_unlockPixels(env, bitmap); 
return jArray; 

}

AM加载库,如:

static { 

    System.loadLibrary("myLibraryName"); 
    } 

这似乎因为它给我的消息,以成功加载​​但再之后,它给了我另一条消息说No JNI_OnLoad found in /data/app-lib/nemo.lungu.receiptor-2/myLibraryName.so 0xa4fe5e78, skipping init如此我不知道这是原因还是其他原因。

回答

2

我需要把extern "C"getPoints()因为JNI面前不明白C++命名转换,所以我在我需要.cpp文件getPoints()方法看起来像extern C JNIEXPORT jfloatArray JNICALL Java_nemo_lungu_receiptor_scanlibrary_ScanActivity_getPoints (JNIEnv *env, jobject thiz,jobject bitmap) {//method implementation}

相关问题