Skip to content Skip to sidebar Skip to footer

Android Unsupportedoperationexception At Canvas.clippath

I am using the image crop library from here https://github.com/lvillani/android-cropimage in my project to crop images stored on device. However, certain users are reporting crash

Solution 1:

On ICS devices, there is a developer option to force hardware acceleration even if the app doesn't request it. That is what is causing the crashes. You should be able to use something like this to force it to use software rendering:

if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) {
   myCustomView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}

Solution 2:

I guess you can draw your view to a off-screen bitmap and copy the bitmap to the on-screen canvas. For instance,

protectedvoiddraw(Canvas canvas) {
    if (mHidden) {
        return;
    }

    Bitmap bitmap = createOffScreenBitmap();
    canvas.drawa(bitmap,0f, 0f, null);

}


privateBitmapdrawOffScreenBitmap(){

    // Draw whatever you want to draw right here.
}

Also, you can use PorterDuffxfermode that supports hardware acceleration, instead of clippath.

Post a Comment for "Android Unsupportedoperationexception At Canvas.clippath"