VectorDrawableCompat Resources$NotFoundException on KitKat and below

To support versions before Lollipop, use

com.android.support:appcompat-v7:24.0.0 (or later)

support library.

And then, instead of

ContextCompat.getDrawable(view.getContext(), id);

use this one

AppCompatResources.getDrawable(view.getContext(), id);

I found the problem: I had my vector-drawables in drawable-anydpi/ - this produces this crash - when i move the drawables to drawable/ it works fine


I was able to use the vector drawables on pre-Lollipop devices by wrapping them in a StateListDrawable (a selector).

More precisely, I created a selector drawable in XML, and then added a single vector drawable in them :

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/vector_ic_action_add" />
</selector>

I then use this "wrapped" drawable in my menu. If you want more information about how it works, check out this very useful post by Chris Banes.