Can I use Android 8.0 Adaptive Icons for a Flutter app?
Asked Answered
W

1

18

How can I use an Adaptive Icon for my Flutter app on Android 8.0 and up? The Create Image Asset dialog in Android Studio says "Project must be built with SDK 26 or later to use adaptive icons", even though my android build.gradle has CompileSDKVersion set to 27. If I define the icon in XML, it doesn't work, it seems to just use the regular legacy app icon.

Woodsy answered 9/6, 2018 at 19:57 Comment(0)
P
20

They work perfectly fine.

Solution

To work with the dialog, you will need to open your Android module in Android Studio.
Flutter.dev article

Navigation is the following in the menu bar: Tools ~> Flutter ~> Open Android module in Android Studio or right-click anywhere in your android folder in the project view and select Flutter ~> Open Android module in Android Studio.

Now you will be able to use the asset dialog normally.

If it still does not work (this does not happen)

If your dialog does not work in your Flutter project, you can easily create an adaptive icon in an Android project and then copy the necessary file, which are:

  • ic_launcher_background.xml (drawable), I think that this is located in values if you chose a color

  • ic_launcher_foreground.xml (drawable-v24)

  • ic_launcher.xml and if you created it ic_launcher_round.xml (mipmap-anydpi-v26)

  • all ic_launcher.png and ic_launcher_round.png (mipmap-hdpi to mipmap-xxxhdpi) for legacy support. I suppose that these are not needed if your minimum SDK requirement is higher than 25

This would cover everything for me. Now, in your AndroidManifest.xml specify android:icon="@mipmap/ic_launcher" for your application, i.e. in your <application> tag, and if needed android:roundIcon:"@mipmap/ic_launcher_round".

Phoebephoebus answered 10/6, 2018 at 9:23 Comment(3)
isn't that a bug that one should open the project again in a different mode for that to work consistently?Dol
New -> Image asset menu was not visible for me when android module is opened. It only appeared after a successful gradle sync, which had failed for me due to a dependency issue.Ineffaceable
@Lahiru Candima how I can use gradle sync in my flutter project. I have made my project in VSCode but when I import it in Andriod Studio 4.1.1 it gives me the error this project is not gradle base. I even tried creating the project in Andriod studio but it does not give me a gradle sync option. Every time I have to import the project again in Andriod Studio to give me the sync option but it still gave me the not gradle based project error. It does not also give me android module.Shantung

© 2022 - 2024 — McMap. All rights reserved.