Xamarin Android - How to rebuild Resource.designer.cs

52,475

Solution 1

As recently as Xamarin Studio 5.6 (build 273) with Xamarin.Android 4.18.0, if you have manually deleted the Resource.designer.cs file from the project, rebuilding will regenerate Resource.designer.cs, but will not add it back into the project. So after attempting to rebuild once, the file will be present in the file system, but not in the project. To fix this, manually add the newly generated file into the Resources folder in the project.

Solution 2

1.Click Resource.designer.cs file from your project.

2.Click CTRL+A (Select All)

3.Click Del (Delete all)

4.Clean and Rebuild your project(if you get message for modified Resource.designer.cs click "Yes to All" button).

you are now get error for first buildings. but your Resource.designer.cs file is regenerated.you can now second build. its works.

Solution 3

I have found that Xamarin studio will stop regenerating the Resources file due to changes in the project file. The top build PropertyGroup should contain entries for

<RootNamespace>**Your_Root_Namespace**</RootNamespace>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
<AndroidApplication>True</AndroidApplication>
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
<AndroidResgenClass>Resource</AndroidResgenClass>
<TargetFrameworkVersion>*your value here*</TargetFrameworkVersion>

and for some reason these just disappear. If you open the csproj of the Android project with a text editor and add these entries it seems to work. I grabbed these entries from a fresh new project I created in Xamarin Studio that was working, which is possibly the easiest way to do this.

Solution 4

I solved this problem removing the character "-" from the name of images in Drawable folder.

Solution 5

method1: Delete the file from the project and also delete bin and obj files and then build the project it should work 100% as i use to do that if i face the same problem if that doesn't work always there is another option

method2: close the application i.e, visual studio, map to c-> users-> -> AppData (Hidden File) -> delete xamarin file from local and roaming

Share:
52,475
Karthik Murugesan
Author by

Karthik Murugesan

SharePoint Solutions Architect

Updated on December 30, 2021

Comments

  • Karthik Murugesan
    Karthik Murugesan over 2 years

    In Xamarin Android - How to regenerate the Resource.designer.cs

    I tried to mark all the XML file's Build Action as "AndroidResource" and still the Resource.designer.cs won't get updated with new values.

    What event trigger generating this file?