Yalantis / uCrop

Image Cropping Library for Android
https://yalantis.com/blog/introducing-ucrop-our-own-image-cropping-library-for-android/
11.88k stars 2.16k forks source link

No implementation found for boolean com.gjmm.parent.crop.task.BitmapCropTask.cropCImg #792

Open gjmm123 opened 2 years ago

gjmm123 commented 2 years ago

最后调用cropAndSaveImage方法时提示No implementation found for boolean com.gjmm.parent.crop.task.BitmapCropTask.cropCImg(java.lang. String, java.lang. String, int, int, int, int, float, float, int, int, int, int) (tried Java_com_gjmm_parent_crop_task_BitmapCropTask_cropCImg and Java_com_gjmm_parent_crop_task_BitmapCropTask_cropCImg__Ljava_lang_String_2Ljava_lang_String_2IIIIFFIIII),why?

shahzadafridi commented 2 years ago

I have spent almost hours and hours to figure this problem, at last, I found a solution for it:

I have shifted this library module to another module in my project and I removed this below line at initially it was giving error so I thought It's not needed then removed

 public class BitmapCropTask extends AsyncTask<Void, Void, Throwable> {

    private static final String TAG = "BitmapCropTask";

    //Don't drop below lines It's mandatory
    static {
        System.loadLibrary("ucrop");
    }

    ....

Later on, I realized that I removed these lines so I reverted back and It works fine.

With this line, It loads the script which is placed in the Jni directory so If It's not loaded then it throws this error.

mans17312 commented 2 years ago

Have any one solved this issue. I want to customize the cropper. But I have the same issue. I think its due to package name?

Ehtisham95 commented 2 years ago

So, finally I found the culprit!

In my case I copied all of the files of the library to a module (To change the UI a bit and remove startActivityForResult() ) and renamed the module to other than "com.yalantis.ucrop".

While Cropping the image, this library picks up the function cropCImg(...) from a "C++" file named uCrop.cpp located in jni folders and in that file the header .h file and the function is defined as JNIEXPORT jboolean JNICALL Java_com_yalantis_ucrop_task_BitmapCropTask_cropCImg. These files are shown in the image.

Issue Since my module was renamed so it did not find the function "Java_com_yalantis_ucrop_task_BitmapCropTask_cropCImg".

Screenshot 2022-09-01 044104

Resolution:

  1. Either change the names from "com_yalantis_ucrop" to your own module name e.g. "com_something_something" in the header com_yalantis_ucrop_task_BitmapCropTask.h and uCrop.cpp file.
  2. OR rename the the module name back to "com.yalantis.ucrop".