26

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?

JJ86
  • 5,055
  • 2
  • 35
  • 64

3 Answers3

27

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.

Thomas Keller
  • 5,933
  • 6
  • 48
  • 80
mixel
  • 25,177
  • 13
  • 126
  • 165
  • Thanks, I will try it in my next sprint. I'm just a little worried about compatibility, because I target 16 and 19 as min SDK in my projects. – JJ86 Dec 20 '17 at 16:33
  • @JJ86 I tested it on API level 16 device and it works perfectly. – mixel Dec 20 '17 at 17:23
  • Thanks a lot for your feedback! – JJ86 Dec 21 '17 at 08:20
  • 1
    Is #2 still valid for Gradle v4+ and Support Library v26+? I would expect at least a compiler warning if you would got this robot icon on some systems... – l33t Apr 05 '18 at 19:48
  • 1
    This works as long as you don't use gradients (which require API 24). – geekley Sep 21 '19 at 02:07
24

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

alanv
  • 23,966
  • 4
  • 93
  • 80
  • 5
    Is this still correct? I am able to use vector drawable like this: – rpattabi May 23 '16 at 13:32
  • 3
    If you're using automatic vector => PNG conversion, it will work fine. If you're only running on API 21+, it might work fine depending on your asset and the launcher being used; however, I don't think Play Store will allow you to upload an APK with a vector icon. – alanv May 23 '16 at 18:48
  • 4
    Contradicting that, I've not only found several apps using vector icons (XML) as launcher icon, but [this tutorial](https://google-developer-training.gitbooks.io/android-developer-fundamentals-course-concepts/content/en/Unit%202/51_c_drawables,_styles,_and_themes.html#creating-icons) even recommends it. So if there's any (official) source to either confirm or reject your statement, a link would be welcome. – Izzy Sep 12 '17 at 16:35
  • @alanv This answer is useful and it deserves a mention: https://stackoverflow.com/a/47910420/2013835 – JJ86 Dec 21 '17 at 08:21
  • 5
    This answer is outdated – Fung Apr 07 '20 at 01:04
  • @Izzy can you update the tutrial link? it shows 404 – George Shalvashvili Mar 10 '23 at 12:03
  • That was six years ago… Maybe archive.org still has it? Unfortunately not, so I have no idea where to look, sorry @GeorgeShalvashvili – Izzy Mar 10 '23 at 22:16
4

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.

Sebastian
  • 2,896
  • 23
  • 36