Goodbye launcher drawables, hello mipmaps!

(UPDATE 18th FEB:  Android Studio 1.1 has been released!)

The upcoming release of Android Studio 1.1 will largely be a bug fixing release. There is one change however that might catch your eye when creating a new project. Projects now create launcher icons in the mipmap resource folders instead of the drawable folders. I am sure we will hear a lot more about this with release of Android Studio 1.1 coming very soon.

Why use mipmaps for your launcher icons?

Using mipmaps for your launcher icon is described as best practice by the Android team. The advantage you get is that you can keep resources in the mipmap folders for all device densities and then strip out other resources from the drawable folders that are not relevant to the specific users device density.

Here is an example, say a user has a device that is classified as xxhdpi. The drawable resources in your apk for all other densities, such as xxxhdpi, are not required and can be stripped out. The launcher icon is different to other resources as it is possible that a higher resolution icon is displayed in the users launcher. If that higher resolution image has been stripped from your drawables folder, then a lower density icon will programmatically be up-scaled. This may cause an unattractive blurry icon.

You may not be producing multiple apk files with stripped out resources to minimize apk size yet. Therefore making the change to mipmaps for your launcher icon will currently not make any difference. That does not mean you should not do it. The best reason for using mipmaps folder is that the Android team want you to and describe it as best practice. They know what new features are in the pipeline for Android and who knows, but maybe they are planning to introduce a new feature where unused resources are automatically stripped for the user when they download apps.

History of launcher mipmaps in Android

The mipmaps resource folders in Android started appearing long before they were introduced to the wider Android development community to use, which started in Android Jelly Bean 4.3. Very little official information came from the Android team about why to use them. Around the time of the release of 4.3, Android framework developer @hackbod announced:

…if you are building different versions of your app for different densities, you should know about the “mipmap” resource directory.  This is exactly like “drawable” resources, except it does not participate in density stripping when creating the different apk targets.

Since that time if you have taken a close look at the apps produced out of Google you will notice that some apps were doing exactly that.  Shipping only the required density but including all densities in the mipmap folders for the launcher icons.

As time went on still there was not much noise out of the Android team about using launcher mipmaps, that was until Lollipop hit AOSP and the new Nexus devices hit the market.  The Android Developers blog posted about preparing your apps for the new Nexus 6 and 9.  This detailed a compelling reason you should use mipmap folders for your app icon and announced the shift of best practice to using mipmaps:

…Provide at least an xxxhdpi app icon because devices can display large app icons on the launcher. It’s best practice to place your app icons in mipmap- folders (not the drawable- folders) because they are used at resolutions different from the device’s current density. For example, an xxxhdpi app icon can be used on the launcher for an xxhdpi device.

Interestingly there is still no update in the Official Android documentation and it still mentions drawable folders being the place for your launcher icons.  I am sure that will change in the coming months as the update to Android Studio is the next step in the progression of the change.

Update May 2015: The Android developer documentation has now been updated to document the purpose of mipmaps.

Creating a new project using launcher mipmaps

Update to Android Studio 1.1, any new project will use the new structure when it is created.

Updating an existing project to use launcher mipmaps

If you have used the excellent tool Android Asset Studio to generate your launcher icons recently you will notice the mipmap change is now reflected in the structure of assets generated. Even if you normally generate your icons through another process this is a great place to start as it shows the format and structure you should be using.

Your assets need to go into a structure much like your previous launcher drawables.

res/
    mipmap-mdpi/ic_launcher.png (48x48 pixels)
    mipmap-hdpi/ic_launcher.png (72x72)
    mipmap-xhdpi/ic_launcher.png (96x96)
    mipmap-xxhdpi/ic_launcher.png (144x144)
    mipmap-xxxhdpi/ic_launcher.png (192x192)

You will also need to change your AndroidManifest.xml to use mipmaps for the launcher.

android:icon="@mipmap/ic_launcher"

9 Comments

Filed under Android 5.0, Android Studio, Image, Nexus

9 responses to “Goodbye launcher drawables, hello mipmaps!

  1. jh902

    These mipmaps, you can still use your garden variety PNG?

    Like

    • Yes, that’s correct. You can simply copy across your existing launcher PNG drawables. Image sizes are the same, the only recommendation is to also provide a xxxhdpi sized launcher icon. Add this to your new mipmap-xxxhdpi folder.

      Like

  2. Is it possible to use xml vector drawable as icon? That would be awesome 🙂 (I know Lollipop can support vector drawable)

    Like

    • I just tried and yes, it works! It is possible to use a Vector Drawable as an app icon if you are targeting API 21+. Also at Google I/O this year the Android team made note that a tool will be added to Android Studio to help automatically generate rasterized images from Vector Drawables to support older platforms. This has not made its way into the preview builds of Android Studio yet.

      Liked by 1 person

  3. Radhika Patel

    I want to know where the actually drawble folder is there in android studio?

    Like

    • The drawable folder for your app is located in ‘…app\src\main\res\drawable’. Android Studio no longer creates the drawable folders for each resolution automatically. If you want to add drawables for a specific dpi, for example ‘drawable-xhdpi’, you will need to manually create this folder in the file system.

      Like

  4. Thank you for great article of android launcher.

    Like

  5. Tushar Mehta

    We can use drawable (hdpi,xhdpi,xxhdpi) folders..Then what is the advantage of mipmap(hdpi,xhdpi,xxhdpi) over drawables…??

    Like

Leave a comment