resource mipmap/myicon not found. How to fix this?

Ronald GANS 136 Reputation points
2021-08-12T14:19:00.83+00:00

I have a VS 2019 Xamarin app. It had previously compiled OK and was distributable.

The app's icon is poorly formed so I updated it.

But now when I rebuild I get the icon changed in the Manifest to android:icon="@mipmap/myicon" and that icon is not found so the build fails.

Even if I change the myicon reference, the build changes it back to myicon which I don't apparently have.

in the mipmap-anydpi-v26 folder i have:

ic_launcher.xml
ic_launcher_round.xml
icon.xml
icon_round.xml
myicon.xml

I'm just a lowly C# and assembler programmer. I find these references confusing.

How can I fix this?

RON

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,292 questions
{count} votes

3 answers

Sort by: Most helpful
  1. JarvanZhang 23,936 Reputation points
    2021-08-13T06:19:24.007+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    when I rebuild I get the icon changed in the Manifest to android:icon="@mipmap/myicon" and that icon is not found so the build fails.

    The icon should be a picture instead of the xml file. The 'ic_launcher.xml' and 'ic_launcher_round.xml' are the configuration files.

       <?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="@mipmap/ic_launcher_foreground"/>  
       </adaptive-icon>  
    

    Please add the icon picture to the resource folder and then set the icon. You could specify the application icon through the Android Manifest section of project Properties. You can see the options that can be used to set the icon, this way can avoid the probem you encounter.

    123021-image.png

    For more details, you could refer to this doc:
    https://learn.microsoft.com/en-us/xamarin/android/deploy-test/release-prep/?tabs=windows#Specify_the_Application_Icon

    Best Regards,

    Jarvan Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Satya 85 Reputation points
    2023-02-02T12:52:23.0066667+00:00

    Hi @JarvanZhang

    Not able to resolve the errors after trying your suggestion.

    I have created a new MAUI project and Manually moved all the code, included packagesin .csproj, fixed all compile time errors and build is now successful without errors.

    Thanks

    0 comments No comments

  3. Todd Albers 1 Reputation point
    2023-12-01T17:11:18.87+00:00

    Since I am not currently targeting Android, I removed the code that was causing this error. This worked.

    In AndroidManifest.xml, I changed the following:

    <application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true"></application>
    

    To the following:

    <application android:allowBackup="true" android:supportsRtl="true"></application>
    

    Note: If you are (or will be) targeting Android, then this obviously is not the best long term solution. But it does stop this error from occurring and I was able to get my upgraded .NET Core app (.NET 7 Upgraded to .NET 8) app to "finally" build and run successfully targeting Windows. I will tackle other platforms later. I don't know how challenging that might be after the upgrade and am reserving the possibility that it could cause me to do what Satya ultimately did above - Create a whole new project and copy over. Hopefully it won't come to that. So, far so good.

    0 comments No comments