Skip to content Skip to sidebar Skip to footer

Underflow In Restore In Android 4.3

I'm getting a IllegalStateException: underflow in restore exception, which is causing my application to crash. This started happening after android 4.3 update. On android 3.0 - 4.2

Solution 1:

The bug is in this section of your code:

if(bitMapWidth+mX<mCanvasWidth){
        canvas.translate(bitMapWidth+mX, 0);    
        if(!mBitMapBuffer.isRecycled()){
            canvas.drawBitmap(mBitMapBuffer, 0, 0, null);
        }
        canvas.restore();                   
    }

You are calling restore() without calling save() first. You don't even need that call to translate() either, you could just pass the x and y coordinates to the drawBitmap() call.

Solution 2:

public void restore ()

Added in API level 1 This call balances a previous call to save(), and is used to remove all modifications to the matrix/clip state since the last save call. It is an error to call restore() more times than save() was called.

Post a Comment for "Underflow In Restore In Android 4.3"