Android-Image-Cropper: 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.
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 11
- Comments: 22
Commits related to this issue
- Issue #553 : java.lang.IllegalArgumentException: Invalid Region.Op - only INTERSECT and DIFFERENCE are allowed — committed to Ch3D/Android-Image-Cropper by Ch3D 6 years ago
- Issue #553 : java.lang.IllegalArgumentException: Invalid Region.Op - only INTERSECT and DIFFERENCE are allowed — committed to frapeti/Android-Image-Cropper by Ch3D 6 years ago
- Merge pull request #1 from Lotus-BProtysk/fixes/issue_553 Issue #553 : java.lang.IllegalArgumentException: Invalid Region.Op - … — committed to Lotus-BProtysk/Android-Image-Cropper by Lotus-BProtysk 6 years ago
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…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.
Reproducible on Pixel 2XL running DP5 as well Lib version: 2.7.0
The issue is reproducable with the following config:
I didn’t even used that. The real reason here is the target API level and depreciation.
Hi, you just need to remove :
.setCropShape(CropImageView.CropShape.OVAL)