0

I am trying to implement Material You adaptive icons. on Maui Android application, but I seem to be failing to do it.

As in How to enable Material You icon for Android for my MAUI app? I went over to https://icon.kitchen/ to generate the appropriate icons and manifests. I dropped the result (res directory) to Project\Platforms\Android\Resources and edited AndroidManifest.xml accordingly.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:supportsRtl="true"></application>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-sdk android:minSdkVersion="28" android:targetSdkVersion="33" />
</manifest>

But I will get a compiler error that tells

Error   APT2260 resource mipmap/ic_launcher (aka com.xyz.project:mipmap/ic_launcher) not found.

This error is likely caused by an issue with the AndroidManifest.xml file or an Android manifest generation attribute in a source code file.    Project C:\<snip>\Project\Platforms\Android\AndroidManifest.xml 1       Normal

I read https://github.com/dotnet/docs-maui/blob/main/docs/user-interface/images/app-icons.md but did not notice anything special there. I could imagine one needs something like

<MauiIcon
      Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) != 'android'"
      Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />

If rename all the ic_launcher icons to appicon and other resources accordingly, the compiler does not complain anymore but the icon has not been updated from what it was previously (the .NET default project icon).

Veksi
  • 3,556
  • 3
  • 30
  • 69

1 Answers1

0

It appeared that I needed to remove the res directory in Android and moved the resources closer to root. Then I cleaned the solution.

I also renamed all applicable resources to appicon. It may due to that they need to be the same in platform specific and general part, but I have not tested this exhaustively.

Alexandar May - MSFT
  • 6,536
  • 1
  • 8
  • 15
Veksi
  • 3,556
  • 3
  • 30
  • 69