IllegalStateException using Ripple Effect Library on Android M Devices

1.6k views Asked by At

Using this library to implement Ripple Effect and it works just fine except on Android M devices.

On Android M Devices getting IllegalStateException that says Underflow in restore - more restores than saves

FATAL EXCEPTION: main
Process: com.example.ripplethings, PID: 20119
java.lang.IllegalStateException: Underflow in restore - more restores than saves
at android.graphics.Canvas.native_restore(Native Method)
at android.graphics.Canvas.restore(Canvas.java:540)
at com.andexert.library.RippleView.draw(RippleView.java:166)
1

There are 1 answers

0
Renjith K N On

It seems like a bug in the library itself on Android 6.0, Possible ways to avoid the bug is

1) Use the com.balysv:material-ripple:1.0.2 library it seems more stable

2) Or you can use place separate layout for 21+ let the Android M handle the ripple itself. Just use the proper ripple holder for layouts and views

3) Or you can modify the library source code itself as per this suggestion

4)A fixed version of this library is available @ git and you can use it in your gradle like

compile 'com.github.Hitta:RippleEffect:82cf00e551'
repositories {
            ...
            maven { url "https://jitpack.io" }
        }