android - Could not find RippleDrawable -


i want create ripple dynamically in code.

code:

if (android.os.build.version.sdk_int >= build.version_codes.lollipop) {       buybutton.setbackground(getpressedcolorrippledrawable(primarycolor, darkervariant)); }  public static rippledrawable getpressedcolorrippledrawable(int color, int darkervariant) {     if (android.os.build.version.sdk_int >= build.version_codes.lollipop) {         colorstatelist colorstatelist = new colorstatelist(                 new int[][]                         {new int[]{}},                 new int[]                         {darkervariant}         );         return new rippledrawable(colorstatelist, new colordrawable(color), null);     }     return null; } 

this works on lollipop makes app crash on gnex (4.3).
error:

could not find class 'android.graphics.drawable.rippledrawable', referenced method fragments.productdetailfragment.getpressedcolorrippledrawable

07-17 12:57:45.757 30992-30992/com.comizzo.ginsonline e/androidruntime﹕ fatal exception: main

java.lang.verifyerror: fragments/productdetailfragment

but rippledrawable never used on gnex because code isn't executed.

how can fix ?

the issue need return drawable instead of rippledrawable in getpressedcolorrippledrawable. otherwise, on pre-lollipop devices, verifyerror.


Comments