android - Native method not found: rabta.pk.chatthahehehe.AndroidUtilities.loadBitmap -


image.c

jniexport void java_rabta_pk_chatthahehehe_androidutilities_loadbitmap(jnienv *env, jclass class, jstring path, jobject bitmap, int scale, int width, int height, int stride) {      androidbitmapinfo info;     int i;      if ((i = androidbitmap_getinfo(env, bitmap, &info)) >= 0) {         char *filename = (*env)->getstringutfchars(env, path, null);         file *infile;          if ((infile = fopen(filename, "rb"))) {             struct my_error_mgr jerr;             struct jpeg_decompress_struct cinfo;              cinfo.err = jpeg_std_error(&jerr.pub);             jerr.pub.error_exit = my_error_exit;              if (!setjmp(jerr.setjmp_buffer)) {                 jpeg_create_decompress(&cinfo);                 jpeg_stdio_src(&cinfo, infile);                  jpeg_read_header(&cinfo, true);                  cinfo.scale_denom = scale;                 cinfo.scale_num = 1;                  jpeg_start_decompress(&cinfo);                 int row_stride = cinfo.output_width * cinfo.output_components;                 jsamparray buffer = (*cinfo.mem->alloc_sarray)((j_common_ptr) & cinfo, jpool_image,                                                                row_stride, 1);                  unsigned char *pixels;                 if ((i = androidbitmap_lockpixels(env, bitmap, &pixels)) >= 0) {                     int rowcount = min(cinfo.output_height, height);                     int colcount = min(cinfo.output_width, width);                      while (cinfo.output_scanline < rowcount) {                         jpeg_read_scanlines(&cinfo, buffer, 1);                          //if (info.format == android_bitmap_format_rgba_8888) {                         if (cinfo.out_color_space == jcs_grayscale) {                             (i = 0; < colcount; i++) {                                 float alpha = buffer[0][i] / 255.0f;                                 pixels[i * 4] *= alpha;                                 pixels[i * 4 + 1] *= alpha;                                 pixels[i * 4 + 2] *= alpha;                                 pixels[i * 4 + 3] = buffer[0][i];                             }                         } else {                             int c = 0;                             (i = 0; < colcount; i++) {                                 pixels[i * 4] = buffer[0][i * 3];                                 pixels[i * 4 + 1] = buffer[0][i * 3 + 1];                                 pixels[i * 4 + 2] = buffer[0][i * 3 + 2];                                 pixels[i * 4 + 3] = 255;                                 c += 4;                             }                         }                         //} else if (info.format == android_bitmap_format_rgb_565) {                          //}                          pixels += stride;                     }                      androidbitmap_unlockpixels(env, bitmap);                 } else {                     throwexception(env, "androidbitmap_lockpixels() failed ! error=%d", i);                 }                  jpeg_finish_decompress(&cinfo);             } else {                 throwexception(env, "the jpeg code has signaled error");             }              jpeg_destroy_decompress(&cinfo);             fclose(infile);         } else {             throwexception(env, "can't open %s", filename);         }          (*env)->releasestringutfchars(env, path, filename);     } else {         throwexception(env, "androidbitmap_getinfo() failed ! error=%d", i);     } 

nativeloader.java

private final static int lib_version = 4;     private final static string lib_name = "chat." + lib_version;     .     .     .     .     .          try {             system.loadlibrary(lib_name);             nativeloaded = true;         } catch (error e) {             log.e(constants.tag, e.getmessage());         } 

logcat

01-29 11:15:34.747 3628-3628/rabta.pk.chatthahehehe e/cutils: chown(/mnt/shell/emulated/0, 0, 0) 01-29 11:15:34.747 3628-3628/rabta.pk.chatthahehehe e/cutils: chown(/mnt/shell/emulated/obb, 0, 0) 01-29 11:15:34.748 3628-3628/rabta.pk.chatthahehehe e/cutils: chown(/storage/emulated/0/android, 0, 0) 01-29 11:15:34.748 3628-3628/rabta.pk.chatthahehehe e/cutils: chown(/storage/emulated/0/android/obb, 0, 0) 01-29 11:15:35.057 3628-3628/rabta.pk.chatthahehehe e/linker: load_library(linker.cpp:759): library "libmaliinstr.so" not found 01-29 11:15:36.348 3628-3779/rabta.pk.chatthahehehe e/tag: native method not found: rabta.pk.chatthahehehe.androidutilities.loadbitmap:(ljava/lang/string;landroid/graphics/bitmap;iiii)v 01-29 11:15:36.384 3628-3780/rabta.pk.chatthahehehe e/tag: native method not found: rabta.pk.chatthahehehe.androidutilities.loadbitmap:(ljava/lang/string;landroid/graphics/bitmap;iiii)v 01-29 11:15:36.411 3628-3784/rabta.pk.chatthahehehe e/tag: native method not found: rabta.pk.chatthahehehe.androidutilities.loadbitmap:(ljava/lang/string;landroid/graphics/bitmap;iiii)v 01-29 11:15:36.427 3628-3786/rabta.pk.chatthahehehe e/tag: native method not found: rabta.pk.chatthahehehe.androidutilities.loadbitmap:(ljava/lang/string;landroid/graphics/bitmap;iiii)v 01-29 11:15:37.527 3628-3851/rabta.pk.chatthahehehe e/tag: native method not found: rabta.pk.chatthahehehe.androidutilities.loadbitmap:(ljava/lang/string;landroid/graphics/bitmap;iiii)v 01-29 11:15:37.528 3628-3850/rabta.pk.chatthahehehe e/tag: native method not found: rabta.pk.chatthahehehe.androidutilities.loadbitmap:(ljava/lang/string;landroid/graphics/bitmap;iiii)v 

you must declare method on java side this:

class androidutilities {    private static native void loadbitmap(string path, android.graphics.bitmap bitmap, int scale, int width, int height, int stride);  } 

Comments