ArthurHub / Android-Image-Cropper

Image Cropping Library for Android, optimized for Camera / Gallery.
Apache License 2.0
6.38k stars 1.34k forks source link

Cropper crashes after selecting a picture and transitioning to crop view. - Android 9 (Pie) #601

Open kurtcarvalho opened 5 years ago

kurtcarvalho commented 5 years ago

No Error message is given but the app crashes in the transition and returns to the screen it was on before the image-cropper is initiated.

`profilePicture?.setOnClickListener { Log.d("CreateProfileFrag","Open picture selection")

        //crop image to circle
        if (context != null) {
            CropImage.activity()
                    .setGuidelines(CropImageView.Guidelines.ON)
                    .setCropShape(CropImageView.CropShape.OVAL)
                    .start(activity!!)
        }
    }`

The cropper continues to work on lower versions of android. <=8 (Oreo)

konstantin-kiriushyn commented 5 years ago

553 I think you might experience this issue. It is still not resolved

abhishekagra commented 5 years ago

Any update guys? I am also facing the same issue in Android Pie. If you know any workaround, then please let me know.

nthreads commented 5 years ago

This can be resolved by the following changes in CropOverlayView

canvas.clipPath(mPath, Region.Op.XOR); //Deprecated
//https://developer.android.com/reference/android/graphics/Canvas#clipPath(android.graphics.Path,%20android.graphics.Region.Op)

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    canvas.clipOutPath(mPath);
} else {
    canvas.clipPath(mPath, Region.Op.INTERSECT);
}
marco97pa commented 5 years ago

I hope this will be fixed soon

arunrajgm commented 5 years ago

Its not working

This can be resolved by the following changes in CropOverlayView

canvas.clipPath(mPath, Region.Op.XOR); //Deprecated //https://developer.android.com/reference/android/graphics/Canvas#clipPath(android.graphics.Path,%20android.graphics.Region.Op)

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    canvas.clipOutPath(mPath);
} else {
    canvas.clipPath(mPath, Region.Op.INTERSECT);
}

Its not working

ajitdubey-mob-ibtech commented 5 years ago

Facing same issue and waiting for new release with fixes.

AhmadIzaz commented 5 years ago

Facing the same problem but no answers found yet

HareshSolankiibl commented 5 years ago

try this,

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                canvas.clipPath(mPath, Region.Op.INTERSECT); //--- hear...
            } else {
                canvas.clipPath(mPath, Region.Op.XOR);
            }
VuHongKy commented 5 years ago

Full fix here: On CropOverlayView, search and change two following places: Place 1:

               if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                    canvas.clipOutPath(mPath);
                    canvas.clipOutRect(rect);
                } else {
                    canvas.clipPath(mPath, Region.Op.INTERSECT);
                    canvas.clipRect(rect, Region.Op.XOR);
                }

Place 2:

           if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                canvas.clipOutPath(mPath);
            } else {
                canvas.clipPath(mPath, Region.Op.XOR);
            }

At the moment, I had to download zip file to local and import to my project, and fix it myself. Hope admin will fix it as soon as possible.

lorraine94588 commented 5 years ago

I am encountering the same issue. I hope this will be fixed soon. Will try VuHongKy's solution otherwise.