flutter_launcher_icons icon indicating copy to clipboard operation
flutter_launcher_icons copied to clipboard

Android adaptive icons are placed in drawable instead of mipmap

Open nioncode opened this issue 6 years ago • 7 comments

Why are adaptive icons placed in drawable instead of mipmap? Android Studio puts them into mipmap and all documentation says that launcher icons should go into mipmap instead of drawable.

I saw in the commits that originally the mipmap directory was used, but @markmooibroek changed it because of some issues (?). Could you explain which issues you saw with using mipmap?

nioncode avatar Jul 01 '19 21:07 nioncode

Still an issue?

ghenry avatar May 28 '20 22:05 ghenry

https://developer.android.com/guide/practices/ui_guidelines/icon_design_adaptive

Seems to say drawable:

<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
    <background android:drawable="@drawable/ic_launcher_background" />
    <foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

mockturtl avatar Jul 24 '20 16:07 mockturtl

I saw in the commits that originally the mipmap directory was used, but @markmooibroek changed it because of some issues (?).

@nioncode Link? The blame indicates they've always been drawable, and I don't find that name in the git log.

mockturtl avatar Jul 24 '20 17:07 mockturtl

Confirmed drawable is working as intended. gradlew clean seems to help flush the cache between test runs.

mockturtl avatar Jul 24 '20 17:07 mockturtl

Android Image Asset Studio uses mipmap for adaptive icons: https://developer.android.com/studio/write/image-asset-studio

Adaptive and legacy launcher icons [...] Image Asset Studio places the icons in the proper locations in the res/mipmap-density/ directories. It also creates a 512 x 512 pixel image that's appropriate for the Google Play store.

davidjaldred avatar Oct 05 '21 06:10 davidjaldred

Confirmed drawable is working as intended. gradlew clean seems to help flush the cache between test runs.

Sorry, I seem to have missed these comments. Sure, drawable works, but it is not correct. Launcher icons should go into the mipmap folders and Android Studio also puts them there. Putting them into drawable works, but has differences in the scaling I guess (which might not be immediately noticeable). But I guess we should follow the official recommendations and not do it differently just because it also works.

nioncode avatar Oct 05 '21 08:10 nioncode

I asked ChatGpt and Bard about this issue and they gave the following answers:

ChatGPT

In Android, both the mipmap and drawable folders are used for storing different types of resources, including icons. The choice of folder depends on the purpose and usage of the icons.

  1. mipmap folder: The mipmap folder is primarily used for storing app launcher icons. These icons are adaptive launcher icons that can automatically adjust their appearance based on the device's display density. Adaptive icons were introduced in Android 8.0 (API level 26) and provide better visual consistency across different devices.

The mipmap folder has different density-specific subfolders, such as mipmap-mdpi, mipmap-hdpi, mipmap-xhdpi, mipmap-xxhdpi, mipmap-xxxhdpi, etc. Each subfolder should contain launcher icons with the corresponding density.

Place the adaptive launcher icons in the appropriate mipmap subfolders. Android will automatically choose the appropriate icon based on the device's screen density.

  1. drawable folder: The drawable folder is used for storing other types of drawables, including icons that are not specifically designed for the launcher. Legacy icons, or non-adaptive icons, should be placed in the drawable folder.

Legacy icons are the ones designed for older versions of Android, prior to the introduction of adaptive icons. These icons do not automatically adapt to different screen densities. If your app targets Android 7.1 (API level 25) or below, you may need to provide legacy icons.

Place the legacy icons in the appropriate drawable subfolders based on the density, such as drawable-mdpi, drawable-hdpi, drawable-xhdpi, drawable-xxhdpi, drawable-xxxhdpi, etc. Each subfolder should contain icons with the corresponding density.

It's worth noting that if your app targets Android 8.0 (API level 26) or higher, it is recommended to use adaptive launcher icons and place them in the mipmap folder. However, you can still provide legacy icons in the drawable folder for backward compatibility with older devices.

To summarize:

  • Adaptive launcher icons: Place them in the appropriate density-specific mipmap subfolders.
  • Legacy icons: Place them in the appropriate density-specific drawable subfolders.

By organizing your icons in this way, you ensure that your app displays the appropriate icons on devices with different screen densities and maintains compatibility with older Android versions.

Bard

Adaptive launcher icons should be placed in the mipmap folder, specifically in the mipmap-anydpi-v26 directory. This is because adaptive icons were introduced in API level 26, and the mipmap folder is used for resources that should be available on all devices, regardless of their screen density.

Legacy icons, on the other hand, should be placed in the drawable folder. Legacy icons are those that do not support adaptive icons, and they will be used on devices that are running API level 25 or lower.

Here is a table that summarizes which icons should be placed in which folder:

Icon type Folder
Adaptive icon mipmap-anydpi-v26
Legacy icon drawable

Here are some additional details about the mipmap and drawable folders:

  • The mipmap folder is used for resources that should be available on all devices, regardless of their screen density. This is done by providing different versions of the resource for different screen densities. For example, there might be a mipmap-hdpi directory for high-density screens, a mipmap-mdpi directory for medium-density screens, and so on.
  • The drawable folder is used for resources that do not need to be available on all devices. This is because the resources in the drawable folder are not scaled to different screen densities.

I hope this helps! Let me know if you have any other questions.

OutdatedGuy avatar Jun 20 '23 12:06 OutdatedGuy