k0bin
k0bin

Reputation: 349

No Resource found that matches the given name Xamarin Android

I always get the error "No Resource found that matches the given name" in my themes.xml file no matter which resource I use or in which I use it. Even if the resource works everywhere else.

Here's some code:

    <?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- the theme applied to the application or activity -->
    <style name="Theme" parent="@android:style/Theme.Holo.Light.DarkActionBar">
        <item name="android:actionBarStyle">@style/ActionBarStyle</item>
        <item name="android:actionOverflowButtonStyle">@style/ActionBarOverflowStyle</item>
    </style>

    <!-- ActionBar styles -->
    <style name="ActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
        <item name="android:background">#008A3D</item>
    </style>

    <style name="ActionBarOverflowStyle" parent="@android:style/Widget.Holo.ActionButton.Overflow">
        <item name="android:src">@drawable/OverflowIcon</item>
    </style>


    <!--Dialog styles-->
    <style name="DialogStyle" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
        <item name="android:background">#008A3D</item>
    </style>
</resources>

I deleted the item node to check whether I can use the resource in code. Proof that it worked; No error:

Upvotes: 8

Views: 7850

Answers (3)

For anyone else that finds this question for different reasons:

Whenever I Copy or Rename a drawable resource in VS 2017, it changes the 'Build Action'.

Double check your resources, and ensure the Build Action is set correctly. In my case, it needed to be 'AndroidResource'

Upvotes: 1

Pooran
Pooran

Reputation: 1680

Remove the image from the project, clean the project, add the properly renamed image(don't try to rename the image once you have added to the project). Should work perfectly.

Upvotes: 0

k0bin
k0bin

Reputation: 349

After googling and fiddling around for a few more hours I figured out that the problem was due to the fact that I use uppercase characters in the file name which works fine everywhere else. This is either a terrible behavior of Android or a bug in Xamarin.

Upvotes: 11

Related Questions