Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not find class 'android.graphics.drawable.RippleDrawable

Android App closing unexpectedly and giving following error in log-cat.

01-22 00:33:58.470 8193-8193/? E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
01-22 00:34:00.010 1173-1173/? E/MyTag: updateClock : 12:34
01-22 00:34:00.015 1173-1173/? E/MyTag: updateClock : 12:34 AM
01-22 00:34:00.051 1173-1173/? E/MyTag: updateClock : 12:34 AM
01-22 00:34:00.080 1432-1432/? E/ActionIcon: time changed: time = 20170122T003400Asia/Calcutta(0,21,19800,0,1485025440)
01-22 00:34:00.086 8210-8210/? E/Zygote: Zygote:  error closing descriptor
                                         libcore.io.ErrnoException: close failed: EBADF (Bad file number)
                                             at libcore.io.Posix.close(Native Method)
                                             at libcore.io.BlockGuardOs.close(BlockGuardOs.java:75)
                                             at com.android.internal.os.ZygoteInit.closeServerSocket(ZygoteInit.java:221)
                                             at com.android.internal.os.ZygoteConnection.handleChildProc(ZygoteConnection.java:879)
                                             at com.android.internal.os.ZygoteConnection.runOnce(ZygoteConnection.java:242)
                                             at com.android.internal.os.ZygoteInit.runSelectLoop(ZygoteInit.java:713)
                                             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:649)
                                             at dalvik.system.NativeStart.main(Native Method)
like image 825
Pankaj Lagad Avatar asked Jan 21 '17 19:01

Pankaj Lagad


1 Answers

For me the problem was the color-selector drawable which I used for the tint value of an ImageView. The crashes occured on API 19 (I assume it's on all devices API < 21).

Problematic code

<ImageView
    android:id="@+id/icon"
    android:layout_width="24dp"
    android:layout_height="24dp"
    android:layout_gravity="center"
    android:src="@drawable/ic_music_note_white_24dp"
    android:tint="@color/color_bottom_navigation_item" />

color_bottom_navigation_item.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:color="#00CCF0" android:state_selected="true" />
    <item android:color="#75848C" />
</selector>

Solution

Remove the android:tint attribute from the XML and set it programatically like so:

ImageView icon = findViewById(R.id.icon);
ColorStateList tint = getResources().getColorStateList(R.color.color_bottom_navigation_item);

Drawable drawable = ContextCompat.getDrawable(getContext(), R.drawable.ic_music_note_white_24dp);
drawable = DrawableCompat.wrap(drawable).mutate();
DrawableCompat.setTintList(drawable, tint);
icon.setImageDrawable(drawable);
like image 140
mbo Avatar answered Nov 02 '22 22:11

mbo