'Resource style not found even though I already remove it and not using in Styles.xml

I created this in Styles.xml

<style name="Content.Right">
    <item name="android:paddingTop">60dp</item>
    <item name="android:paddingLeft">20dp</item>
    <item name="android:paddingRight">20dp</item>
    <item name="android:paddingBottom">20dp</item>
    <item name="android:background">@drawable/bg_round_corner_top_right</item>
    <item name="android:backgroundTint">@color/white</item>
</style>

Then, suddenly I removed this style because I will not using it anymore, but an error occur.

Error message

I already try to clean and rebuild the project, and reopen the Visual Studio but this error still occur. Also there is no file that open when I click the error.

Additionally, after remaining the style another error occur

enter image description here

So I added another style in Style.xml to fix the error.

enter image description here

Why this error occur and what is the way to fix this?

Other information:

  • Microsoft Visual Studio Enterprise 2022 Version 17.1.4
  • Xamarin android project
  • Android 12 framework
  • Windows 10


Solution 1:[1]

I was able to reproduce this issue. enter image description here

Change:

<style name="Content.Right">
    <item name="android:paddingTop">60dp</item>
    <item name="android:paddingLeft">20dp</item>
    <item name="android:paddingRight">20dp</item>
    <item name="android:paddingBottom">20dp</item>
    ....
</style>

To:

<style name="Content_Right">
    <item name="android:paddingTop">60dp</item>
    <item name="android:paddingLeft">20dp</item>
    <item name="android:paddingRight">20dp</item>
    <item name="android:paddingBottom">20dp</item>
   ...
</style>

You could refer to Naming Practices below for xml:

  • Avoid "-". If you name something "first-name", some software may think you want to subtract "name" from "first".
  • Avoid ".". If you name something "first.name", some software may think that "name" is a property of the object "first".
  • Avoid ":". Colons are reserved for namespaces (more later).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Wendy Zang - MSFT