Reputation: 1120
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?
Upvotes: 65
Views: 57535
Reputation: 391
in my case problem was solved by switching Access Modifier in Resource page from 'No code generation' to 'Public'
Upvotes: 0
Reputation: 512
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)
Upvotes: 6
Reputation: 1
I faced the same issue in Visual Studio. The resource designer file is only generated when there is a change in the resource I applied following steps to generate the required resource.designer.cs file * Added a dummy image in the resources * Cleaned the project * Rebuild the project New resource.designer.cs generated.
Upvotes: 0
Reputation: 113
I solved this problem removing the character "-" from the name of images in Drawable folder.
Upvotes: 6
Reputation: 1
For people that are still having this issue, when you look at the error list some error might say something like "no resource found that matches the given 'toRightOf @id/(name of the resource)' (or any other position in relative layout)... you must highlight all the code of the resource (in the axml file) that has the id, cut, save all, then paste it and rebuilt... then your Resource.Designer.cs will regenerate! hope it helps.
Upvotes: 0
Reputation: 131
It would seem that this can happen for a number of reasons. One step that can help reveal the problem is to increase your build output verbosity in Visual studio: Tools -> Options -> Build and Run -> change the "MSBuild project build output verbosity" to "Diagnostic".
In my case, one of my controls did not have an Id so it led to the Resource.Designer.cs not updating (but failing to do so silently).
The file started updating again once I added an Id.
NOTE: You will probably want to change the build output verbosity back to normal after you find your issue.
Upvotes: 3
Reputation: 1557
It happened to me a few times, and every time the problem was not coming from the generation of the file itself, but from a malformed android resource. So if that happens after you merged something from your repository, double check your android resources (colors, strings, etc), for any malformed XML code.
Upvotes: 1
Reputation: 438
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
Upvotes: 3
Reputation: 286
I had the exact same issue and none of the answers here worked. Finally I figured that I had some image references in some layouts that did not exist yet. It seems if you have a broken source path, Resource.Designer.cs stops updating without any error. Finally after removing the reference images, the issue was resolved and the Resource.Designer.cs got updated.
Hope this helps someone!
Upvotes: 0
Reputation: 2745
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.
Upvotes: 26
Reputation: 131
For the rebuild project solution to work you have to edit the file that generates it and then rebuild the project.
Upvotes: 0
Reputation: 4104
The Resource.designer.cs folder would update as @Brendan Zagaeski mentioned.
However, since it seems like that didn't solve your problem it looks like Xamarin didn't recognize any of the changes you made. At least this is what happened to me.
I ended up solving it by renaming the generated "Layout" folder to "layout" ( I did the same for drawable and values). After that, just by building the project again the Resource.Designer updated successfully.
Hope this helps someone.
Upvotes: 1
Reputation: 2882
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.
Upvotes: 86
Reputation: 10756
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.
Upvotes: 17
Reputation: 17
It's easier than it seems...
http://docs.xamarin.com/recipes/android/general/projects/specify_default_namespace/
You can rename your project by using find/replace, but the resources file will use whatever is set for 'default namespace' in the Main Settings and will continue to revert to this name even if you manually edit the Resource.designer.cs file in or out of Xamarin.
Upvotes: 0
Reputation: 33048
The generated Resources.designer.cs
class will be updated if you rebuild your project.
You can find this information at: http://docs.xamarin.com/guides/android/getting_started/hello%2C_world
Upvotes: -4