In Android Studio 3.0, once we create a project, a folder named mipmap-anydpi-v26
is automatically created in the res
directory. What actually does it do? Why do we need it? How will we utilize it for development purposes?
Also, there are two XML files automatically created in this folder after project setup. Why do these XML files reside in a mipmap folder? I thought we should keep all XML files in a drawable folder instead of mipmap.
I have found an explanation about this, here is some context:
To add an adaptive icon that replaces all PNGs on API 26+ devices, you’ll add a
res/mipmap-anydpi-v26/ic_launcher.xml
file that looks like this:By placing it in the
mipmap-anydpi-v26
folder, the resource system will use it in preference over any files in the other dpi folders (exactly what you want, since this file is replacing all of them) and that it should only be used in API 26+ devices.Android Studio 3 creates an adaptive icon for your app which is only available in SDK 26 and up. Launcher icons should be put into the mipmap folders.
If you look at your manifest, you can see that it references
ic_launcher
If you look in your mipmap folder, you see your normal 5 different launcher icons which will be used for anything lower than SDK 26. For SDK 26 and up, it uses the XML files from the
anydpi-v26
folder to make use of adaptive icon.Both answers above give pretty good summary of what
mipmap-anydpi-v26
folder does but I feel why part is missing. So heres my 2 cents.anydpi: These resources take precedence in any dpi. So even if you have
mipmap-hdpi
ormipmap-mdpi
matching with current devices density, resource from mipmap-anydpi will always be picked up.anydpi-v26: This is an additional filter over just anydpi. This says resources will always be picked up from
anydpi-v26
regardless of devices density only if SDK/API level is 26 or higher(Oreo).So you can have mipmap-anydpi-v26 or drawable-anydpi-v26. All resource folders will follow above logic.
This is because
ic_launcher.xml
is used to describe adaptive icon for your app which is only available in SDK 26 and up as mentioned by other answers. Hope this helps.