Android-Image-Cropper
Android-Image-Cropper copied to clipboard
java.lang.IllegalArgumentException: Invalid Region.Op - only INTERSECT and DIFFERENCE are allowed
Running the crop activity on android P dp3 causes this error. it causes my app to crash. I'll put the full stacktrace below:
06-08 17:49:51.044 16313-16313/nl.jolanrensen.clockwidget E/AndroidRuntime: FATAL EXCEPTION: main Process: nl.jolanrensen.clockwidget, PID: 16313 java.lang.IllegalArgumentException: Invalid Region.Op - only INTERSECT and DIFFERENCE are allowed at android.graphics.Canvas.checkValidClipOp(Canvas.java:779) at android.graphics.Canvas.clipPath(Canvas.java:1007) at com.theartofdev.edmodo.cropper.CropOverlayView.drawBackground(CropOverlayView.java:635) at com.theartofdev.edmodo.cropper.CropOverlayView.onDraw(CropOverlayView.java:579) at android.view.View.draw(View.java:20205) at android.view.View.updateDisplayListIfDirty(View.java:19080) at android.view.View.draw(View.java:19933) at android.view.ViewGroup.drawChild(ViewGroup.java:4333) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112) at android.view.View.updateDisplayListIfDirty(View.java:19071) at android.view.View.draw(View.java:19933) at android.view.ViewGroup.drawChild(ViewGroup.java:4333) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112) at android.view.View.updateDisplayListIfDirty(View.java:19071) at android.view.View.draw(View.java:19933) at android.view.ViewGroup.drawChild(ViewGroup.java:4333) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112) at android.view.View.updateDisplayListIfDirty(View.java:19071) at android.view.View.draw(View.java:19933) at android.view.ViewGroup.drawChild(ViewGroup.java:4333) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112) at android.view.View.updateDisplayListIfDirty(View.java:19071) at android.view.View.draw(View.java:19933) at android.view.ViewGroup.drawChild(ViewGroup.java:4333) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112) at android.view.View.updateDisplayListIfDirty(View.java:19071) at android.view.View.draw(View.java:19933) at android.view.ViewGroup.drawChild(ViewGroup.java:4333) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112) at android.view.View.draw(View.java:20208) at com.android.internal.policy.DecorView.draw(DecorView.java:780) at android.view.View.updateDisplayListIfDirty(View.java:19080) at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:685) at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:691) at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:799) at android.view.ViewRootImpl.draw(ViewRootImpl.java:3263) at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3079) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2459) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1447) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7130) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:935) at android.view.Choreographer.doCallbacks(Choreographer.java:747) at android.view.Choreographer.doFrame(Choreographer.java:682) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:921) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6642) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Edit: this only seems to happen with OVAL. RECTANGLE doesn't make it crash.
Reproducible on Pixel 2XL running DP5 as well Lib version: 2.7.0
The issue is reproducable with the following config:
compileSdkVersion=28
buildToolsVersion=28.0.1
I've submitted a pull request which addresses this issue https://github.com/ArthurHub/Android-Image-Cropper/pull/588
I've setup the library and I'm not getting any error on the Android P emulator. Is this issue exclusive to real devices ?. Anyway, the PR #588 still has to be accepted since the used API is deprecated
I've got this crash error both at Android P emulator and real devices using Android P.
For me it only occurs when I set cropshape to CropImageView.CropShape.OVAL. With the default setting it works fine.
- Google Pixel
- Android 9
Hi Team, I am facing the same issue in Android P. Some one fixed the issues on git and make pull request to merge code. Admin please release new version ASAP. Thanks,
same issue here, both api 28 emulator and pixel, any udpate?
I got around the issue with this for now:
.setCropShape(Build.VERSION.SDK_INT >= Build.VERSION_CODES.P ? CropImageView.CropShape.RECTANGLE : CropImageView.CropShape.OVAL)
It shows the cropping view as a rectangle in Android P and above, but at least it doesn't crash. I'll change it back to oval only once the problem is resolved...
Also same issue here in my Nokia 6.1 Plus running on Android Pie. I think it's a problem starting with Android Pie
The same here. Pixel 2, Android Pie, CropImageView.CropShape.OVAL
The same here. Pixel 2, Android Pie, CropImageView.CropShape.OVAL
It was fixed with the latest version, upgrade the lib in your project
It causes this exception when rotating image too on Android P. Any workaround or fix?
I just went through some documentation and found that canvas.clipRect(rect, Region.Op.XOR);
this line is the culprit if the app is targeting android P since as of API Level API level P only Region.Op.INTERSECT and Region.Op.DIFFERENCE are valid Region.Op parameters. Hence, the crash.
Hi,
you just need to remove :
.setCropShape(CropImageView.CropShape.OVAL)
Hi, you just need to remove :
.setCropShape(CropImageView.CropShape.OVAL)
I didn't even used that. The real reason here is the target API level and depreciation.
Same issue occur in my end, it was fixed now Change the targetSdkVersion 27 in build.gradle.
It's still an issue.
https://developer.android.com/reference/android/graphics/Canvas#clipRect(android.graphics.RectF,%20android.graphics.Region.Op) canvas.clipRect(Rect, Region.Op.REPLACE) 是过时的,在targetSdkVersion 28,android P上出现这个 issue;
getting the same issue even targetSdkVersion 27
Full fixed here: https://github.com/ArthurHub/Android-Image-Cropper/issues/601#issuecomment-476978786
CropImage
.activity(imageuri)
.setGuidelines(CropImageView.Guidelines.ON)
.setCropShape(Build.VERSION.SDK_INT >= Build.VERSION_CODES.P ? CropImageView.CropShape.RECTANGLE : CropImageView.CropShape.OVAL)
.setMultiTouchEnabled(true)
.setFixAspectRatio(true)
.start(this);
this will be fixed on android P below