Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin Android - How to rebuild Resource.designer.cs

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?

like image 238
Karthik Murugesan Avatar asked Aug 20 '13 23:08

Karthik Murugesan


6 Answers

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.

like image 75
Brendan Zagaeski Avatar answered Nov 12 '22 03:11

Brendan Zagaeski


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.

like image 42
Ali Yousefi Avatar answered Nov 12 '22 03:11

Ali Yousefi


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.

like image 18
AlexC Avatar answered Nov 12 '22 01:11

AlexC


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

like image 6
chlara Avatar answered Nov 12 '22 01:11

chlara


In Visual Studio 2019, if you deleted Resources.Designer.cs, just right click "Resources.resx" file in solution explorer and choose "Run custom tool"

This will recreate the file.

"ResXFileCodeGenerator" must be set in Resources.resx file properties (but is set by default) enter image description here

like image 6
Jean-Daniel Gasser Avatar answered Nov 12 '22 03:11

Jean-Daniel Gasser


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

like image 3
ROHIT MANDALAPU Avatar answered Nov 12 '22 01:11

ROHIT MANDALAPU