Android.Content.Res.Resources+NotFoundException: Resource ID #0x0

I’ve just created a simple MasterDetailPage and in the code I inserted an icon for the left page with:

public MainPage() {
    InitializeComponent();

    BackgroundColor = Color.FromHex("#007acc");
    Icon = "settings.png";
}

I tried to deploy my app on an Android emulator but I can’t deploy it because Android.Content.Res.Resources+NotFoundException: Resource ID #0x0.

I checked everthing and evething seemed fine. The problem is the icon!

You have to remove Icon from the code and in the XAML page type the following code:

  <ContentPage.Icon>
    <OnPlatform x:TypeArguments="FileImageSource">
      <OnPlatform.iOS>settings.png</OnPlatform.iOS>
    </OnPlatform>
  </ContentPage.Icon>

Happy coding!

Leave a comment

Send a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.