java.lang.UnsatisfiedLinkError: Native method not found in Android -


could me locate error, have looked @ looked can't seem find it, trying run code keeps giving me error java.lang.unsatisfiedlinkerror: native method not found: nemo.lungu.receiptor.scanlibrary.scanactivity.getpoints:(landroid/graphics/bitmap;)[f below activity method getpoints():

   public native float[] getpoints(bitmap bitmap);  

the header version of method getpoints():

jniexport jfloatarray jnicall  java_nemo_lungu_receiptor_scanlibrary_scanactivity_getpoints (jnienv *, jobject, jobject); 

and implementation of method getpoints() in .cpp file:

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 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);      (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 loading library like:

  static {      system.loadlibrary("mylibraryname");    } 

which seems load gives me message added shared lib /data/app-lib/nemo.lungu.receiptor-2/mylibraryname.so 0xa4fe5e78 again after gives me message no jni_onload found in /data/app-lib/nemo.lungu.receiptor-2/mylibraryname.so 0xa4fe5e78, skipping init not know if cause or else.

i needed put extern "c" in front of getpoints() because jni not understand c++ naming conversion, getpoints() method in .cpp file needed extern c jniexport jfloatarray jnicall java_nemo_lungu_receiptor_scanlibrary_scanactivity_getpoints (jnienv *env, jobject thiz,jobject bitmap) {//method implementation}


Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -