I\'m getting a Resources$notfoundexception on older (pre-L) devices. I\'m including the full stacktrace below.
My version of the support library is the latest (24.1
Instead of:
ContextCompat.getdrawable()
Try using:
AppCompatDrawableManager.get().getDrawable()
Another solution,
in addition to AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
is to wrap your vector drawable into another drawable:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_your_vector"/>
</selector>
Might be useful when you use as a drawable for a TextView (i.e. DrawableLeft)
Accepted answer is not covered all cases. It will not work on Android 4.0.3/4.1.1/4.1.2 platform with 25.x.x support library. The right way to fix problem with abc_ic_ab_back_material.xml
is to override homeAsUpIndicator
attribute in your theme. For example, my theme is inherited from Theme.AppCompat.Light.NoActionBar
. As for value of mentioned attribute, you can use @drawable/abc_ic_ab_back_mtrl_am_alpha
or your custom 'back' drawable.
Please make sure you are using AppCompatActivity instead Activity. If you're using AppCompat's theme, then you also need to use it's Activity.
private resources its treated differently at compile time and runtime..to fix I usually take the offending private resource and backport it to my app in my res files
The answer to this turned out to be buried at the bottom of this guide:
https://medium.com/@chrisbanes/appcompat-v23-2-age-of-the-vectors-91cbafa87c88#.xucjbsts0
It turns out that all you need to add this line in at the beginning of the activity that will use the resource:
static {
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}