Do this when upgrading to Support Library 23.2 or your app might CRASH


UPDATE 2016.03.12.####

It looks like Google changed its mind and with Support Library version 23.2.1 they reverted dependency on Vector Drawables for the appcompat support library so your app won't crash from using the Toolbar. This means that if you update to this version you no longer need to add the flags to your build.gradle file just because you use appcompat. You may still need it if you use VectorDrawables and your app has a minimum sdk below 21. Here you can find the official changelog for the update:

Original post####

Google just introduced Android Support Library version 23.2.0. It contains a number of new and exciting features, and one of them is the backported versions of Vector Drawables: VectorDrawableCompat and AnimatedVectorDrawableCompat. They eliminate the need to use separate pngs for every screen densities resulting in smaller apks. The Android dev team itself switched to using Vector Drawables in the support libraries starting from this release.

This step may cause some headaches though if you are not careful. If you have an app that has a minimum sdk below 21 (Lollipop) your app might crash if you upgrade to the latest Support Library and don't make the changes below.

To be exact, you could get this exception on a device running KitKat or an older Android version:

Caused by: android.content.res.Resources$NotFoundException: File res/drawable-v19/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020016
 at android.content.res.Resources.loadDrawable(Resources.java:2097)
 at android.content.res.Resources.getDrawable(Resources.java:700)

Luckily there is an easy fix, depending on the Gradle version you use. For the new, 2.0 Gradle plugin it is a one liner:

// Gradle Plugin 2.0+  
 android {  
   defaultConfig {  
     vectorDrawables.useSupportLibrary = true  

And for Gradle version 1.5 (there is no such fix for older Gradle versions):

// Gradle Plugin 1.5  
 android {  
   defaultConfig {  
     generatedDensities = []  

  // This is handled for you by the 2.0+ Gradle Plugin  
  aaptOptions {  
    additionalParameters "--no-version-vectors"  

With these options in placein your app's build.gradle file, everything will be back to normal even on older devices. Also, don't forget to upgrade the Gradle plugin to 1.5.0 or newer, as older versions are not supported.

There is a lot more going on with the new 23.2 Support Library that worth checking out so if you want to learn more, follow the links at the end of this post or watch the video below.

Sources and further reading:


Follow us on social media

Ezek is érdekelhetnek

AutSoft Zrt.
Gábor Dénes utca 4, Infopark C épület, I. emelet,
1117 Budapest, Magyarország

+36 70 907 3300
magnifiercross linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram