Android vector drawable for launcher icon and other images on Android N-ThrowExceptions

Exception or error:

I’m going to use vector drawable feature for action bar icons and notification icon, on my app.

With the announce of Android N, one of his most important feature is Screen Zoom (on Accessibility Improvements section). Another interesting feature is Multi-window support (see link if you want more info).

Does this means that we should use vector drawable also for launcher icon and other images used on app?

How to solve:

Vector drawable is not supported for launcher icons. You are, however, encouraged to use it everywhere else.

###

You can use vector drawables as launcher icon if you follow these steps:

  1. Place vector launcher icon under drawable directory. You can’t place vector drawables in mipmap directory because they will work only in API levels 21 and above. As you possible know it’s recommended to place PNG launcher icons under mipmap-<density> directories instead of drawable-<density> ones, and this matters because if you have a split apk build or use the new aab format to upload your app (“Google Dynamic Delivery”), both processes will remove all drawable-<density> directories except the one for the current density.

  2. Remove vectorDrawables.useSupportLibrary = true in build.gradle defaultConfig section if you set it earlier. This will enable build-time PNG generation for vector drawables for API levels lower then 21. If you do not remove this option than android:icon attribute of the <application> tag will load default Android “green robot” icon.

I tested it on API level 16 device and it works perfectly.

###

It seems vector drawables are now supported for launcher icons.
I have recently uploaded and published an app (to alpha) with a vector drawable as a laucher icon.

Leave a Reply

Your email address will not be published. Required fields are marked *