How should we use the mipmap folders added with android 4.4?
Asked Answered
G

1

4

I recently installed one more Android SDK to Android Studio, the SDK version 4.4 (API level 19), and after using it with my project, it added a set of mipmap folders in the project's res folder (res/mipmap).
I neither understand why, or how to use them.

I read another question about it here on SO.
The answer to it said that:

The mipmap folders are for placing your app icons in only. Any other drawable assets you use should be placed in the relevant drawable folders as before.

According to this Google blogpost:

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.

I still don't get the reason to this.
Why cant we just place the app icons in the res/drawable folders too?

Also, if only the app icon should be placed in the mipmap folders, how do I create other drawable assets and place them in the drawable folders with the Android Studio Image Asset wizard? (Accessed by right clicking in the project, selecting New > Image Asset)

Gleesome answered 6/3, 2015 at 23:43 Comment(1)
Possible duplicate of mipmap drawables for iconsBoomerang
J
10

Why cant we just place the app icons in the res/drawable folders too?

Oh, you can. Google doesn't recommend it, that's all.

Quoting myself from Version 6.5 of my book:

While drawable resources might be removed when packaging an APK, such as for the Gradle for Android split system for making density-specific editions of an app, mipmap resources are left alone, apparently

This is because launcher icons may be pulled from a higher-density bucket than the regular device density that is used for all other drawables. Putting them in res/mipmap-*/ directories means that we won't inadvertently get rid of them as part of optimizing APK size.

(why they didn't handle this in a better way, I have no idea)

how do I create other drawable assets and place them in the drawable folders with the Android Studio Image Asset wizard? (Accessed by right clicking in the project, selecting New > Image Asset)

The Image Asset wizard only puts launcher icons in res/mipmap-*/ directories. If you choose the other icon types, they will go in res/drawable-*/. And, of course, the Image Asset wizard itself is optional.

Joey answered 6/3, 2015 at 23:56 Comment(4)
Related: I like to support authors when our circles intersect. I just went on Amazon to buy a copy of your book The Busy Coder's Guide to Android Development. It seems a used copy is going for $267 USD. It looks like the new one is a bargain at $5,842.Geny
@Joey I don't build one APK for each density. Is that something I should do when releasing it? And, if I don't build it for different densities, there is no real difference between the folders, right? Also, why I wondered about the Image Asset wizard was because it scales one image to fit all densities, instead of me having to resize them manually. Thanks!Gleesome
@TheDDestroyer12: "Is that something I should do when releasing it? " -- not usually. It's mostly there for apps with a huge number of drawables, where there might be benefits to the user by stripping out ones that won't get used, based on the device's density. "And, if I don't build it for different densities, there is no real difference between the folders, right?" -- mipmap has fewer characters than drawable. :-) But, otherwise, yes, they should be equivalent. The fact that mipmap is ill-documented, though, means I'd lean towards drawable.Joey
@jww: The book has been published as a digital-only title for a few years now. The print ones you are seeing on Amazon are seriously out of date, and are a fair bit more expensive than is my Warescription. Thanks for the interest!Joey

© 2022 - 2025 — McMap. All rights reserved.