Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I fix this warning in android studio? "Monochrome icon is not defined"

Tags:

android

I used the UI to add an adaptive icon and I get this error:

Monochrome icon is not defined If android:roundIcon and android:icon are both in your manifest, you must either remove the reference to android:roundIcon if it is not needed; or, supply the monochrome icon in the drawable defined by the android:roundIcon and android:icon attribute. For example, if android:roundIcon and android:icon are both in the manifest, a launcher might choose to use android:roundIcon over android:icon to display the adaptive app icon. Therefore, your themed application iconwill not show if your monochrome attribute is not also specified in android:roundIcon. Issue id: MonochromeLauncherIcon

This error message is not clear and also not the way to fix it.

like image 477
Ronen Festinger Avatar asked Oct 15 '25 00:10

Ronen Festinger


1 Answers

You probably have an adaptive launcher icon like:

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

Google wants:

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

(along with a suitable ic_launcher_monochrome mipmap)

This is in support of the Material You initiative.

If, like many developers, your graphic designers and marketers think that Material You is utterly ridiculous, you can add tools:ignore="MonochromeLauncherIcon" to opt out of the Lint check:

<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    tools:ignore="MonochromeLauncherIcon">
    <background android:drawable="@drawable/ic_launcher_background" />
    <foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
like image 90
CommonsWare Avatar answered Oct 17 '25 13:10

CommonsWare