Xamarin Android - How to rebuild Resource.designer.cs
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.