Search code examples
androidandroid-vectordrawable

Is vectorDrawables.useSupportLibrary flag needed for minSdkVersion > 21


I want to enable AndroidX vector support (use app:srcCompat, AppCompatResources.getDrawable) Do I need to enable vectorDrawables.useSupportLibrary if project minSdkVersion > 21?

defaultConfig {
    vectorDrawables.useSupportLibrary = true
}

Nick Butcher says that we do need. But I'm in doubt.

Q: Is my understanding correct that this step can be skipped on minSdkVersion=21 and above?

A: No! If you do that then you can’t use newer features on older platforms e.g. fillType was added in API24, if you omit this flag then you won’t be able to use this feature on APIs 21–23.


Solution

  • Yes, You can skip this if your minSdkVersion > 21.

    This is for minSdkVersion below 21. If you have a vectorDrawable image in your res/drawable, the Gradle plugin will automatically generate raster PNG images for API level 20 and below during build time. This means you only need to update and maintain your vector asset for your app project and Android Studio can take care of image conversion process.