fluttercommunity / flutter_launcher_icons

Flutter Launcher Icons - A package which simplifies the task of updating your Flutter app's launcher icon. Fully flexible, allowing you to choose what platform you wish to update the launcher icon for and if you want, the option to keep your old launcher icon in case you want to revert back sometime in the future. Maintainer: @MarkOSullivan94
https://pub.dev/packages/flutter_launcher_icons
MIT License
1.99k stars 393 forks source link

Android adaptive icons are placed in drawable instead of mipmap #116

Open nioncode opened 5 years ago

nioncode commented 5 years ago

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?

ghenry commented 4 years ago

Still an issue?

mockturtl commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

davidjaldred commented 2 years ago

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.

nioncode commented 2 years ago

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.

OutdatedGuy commented 1 year ago

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. 2. `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:

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

islandYzx commented 2 months ago

As an Android developer with a little OCD, placed the adaptive icons in drawable is different with AS which make me feel uncomfortable. I can't accept it.