[FIXED] .NET MAUI app + MediaPicker is crashing with Android.Content.Res.Resources+NotFoundException


In my .NET MAUI app, I use the built-in MediaPicker to access user’s photos. The app works fine until I tap the icon to access the photos. It then crashes with the following error message:

Android.Content.Res.Resources+NotFoundException Message=Drawable
com.mycompany.myapp:mipmap/appicon with resource ID #0x7f0d0000

I did replace the app icon recently and I also noticed that the app is not using it when I run the app on an actual device. I simply put a new svg file in the Resources/AppIcon folder with the same name as the original i.e. appicon.svg.

In the properties for this file, I set it as MAUIICON.

This is what’s in the project file:

<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" />

In case, it’s helpful, this is how I’m using the MediaPicker:

   var result = await MediaPicker.PickPhotoAsync(new MediaPickerOptions
         Title = "Pick Image"

   if (result == null)
catch(Exception e)
   // Log error

I never hit the catch block. It just crashes with the error message I mentioned above.

Any idea how to address this issue?


The issue is definitely the AppIcon. Looks like .NET MAUI is not generating correct size icons from the svg that I had under Resources\AppIcon.

The workaround is to manually create the necessary icons — in my case, I only created one 72×72 — and placed them in Platforms\Android\Resources\mipmap folder. In my case, the Resources folder was there under Platforms\Android so I just had to create the mipmap folder.

I then had to go into AndroidManifest.xml file and correctly link them:

<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true"></application>

So, in my case the file name for the app icon I manually generated is ic_launcher.png. I did have to have a second image named ic_launcher_round.png.

Looks like .NET MAUI is supposed to do this work but it’s not doing it.

The second bonus — which it shouldn’t be — is that when I now install the app on a device, I see the correct app icon for my app.

Here’s a link to the issue I reported. Anyone experiencing this issue should up vote it so that it’ll get the team’s attention.

Answered By – Sam

Answer Checked By – Terry (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published