Xamarin.Android Resource.Designer.cs file not updating problem.

The Xamarin.Android stops regenerating or updating the resource files for mainly two reasons which I have figured out, out of lots of search on the net and introspection.

The Android Studio, rebuild the project every time you save any file. Unlike the Android Studio Visual Studio doesn’t build the project on every save one performs, so we have to clean and rebuild the solution in order to update the Resource.designer.cs file with latest resources.

But but some time the Visual Studio fails to update the resource file despite of rebuilding the solution.

So to resolve this problem here what we have to do.

 

1st Check of errors in layout.

The Visual Studio doesn’t update the Resource.designer.cs if there is any errors in the layout files. Once all the errors are rectified rebuild the solution again and if the problem still persists we need to perform the next step.

 

2nd Edit Project File

To edit the project file we need to unload the project first. Then edit the and following tag in “PropertyGroup” tag. Comment the following tags given below.

<AndroidApplication>True</AndroidApplication>
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
<AndroidResgenClass>Resource</AndroidResgenClass>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>

<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidEnableSGenConcurrent>true</AndroidEnableSGenConcurrent>

And add the following lines before the end of tag “PropertyGroup”.

<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidApplication>True</AndroidApplication>
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
<AndroidResgenClass>Resource</AndroidResgenClass>

Save the .csproj file and reload the project and once again rebuild and all the newly added resources will be available in the Resource.designer.cs file.

 

Note: Before launching the app on the emulator or physical device restore the .csproj file by commenting the newly added tags and uncommenting the commented lines.