14

Computer Specification

  • Visual Studio 2015 Enterprise Update 3
  • Xamarin 4.2.0.719
  • Xamarin.Android 7.0.1.6
  • Xamarin.iOS 10.2.0.4

Problem Details

Resource.designer.cs Not Updating in Xamarin.Droid project.

  1. Tried to delete
  2. Tried to Clean content and rebuild
  3. Restart Solution
  4. Restart Computer
  5. Create new Project.
  6. Re-add files as Android Resource
  7. Tried to delete the Resources.Designer.cs file

I tried all of the posts below that i might think this is a duplicate post:

Also tried official link from Xamarin:

I tried this one from Codeproject where it says [Solved] But also didn't work for myself:

Community
  • 1
  • 1
Anderson Oki
  • 579
  • 4
  • 17
  • Were you able to find any solution? I'm having this same issue – Jelle Apr 16 '17 at 00:08
  • Yeah. Check for duplicate Id on the project. The File was not being generated because of an Id Issue. There was 2 Ids with same name. – Anderson Oki Apr 16 '17 at 00:10
  • Do you mean Id's in the resource file? (this shouldn't be a problem right?) or do you mean file names in the project file? – Jelle Apr 17 '17 at 07:34
  • Neither. I mean in @+ids in the axml files. If any duplicate it will crash the Resources generation. E.g: file1.axml there is an Id abc and file2.axml there is an Id abc. It will crash. – Anderson Oki Apr 17 '17 at 07:36
  • did not work for me :/ thanks for helping though! – Jelle Apr 17 '17 at 23:52
  • Maybe this [answer ](https://stackoverflow.com/a/15475131/5666214) solves your problem. – João V. Nov 04 '19 at 12:34

5 Answers5

2

I had a similar problem where there was an error in a resource file which prevented the resource.designer.cs file from updating. In my case the issue was that I had added a few images which had illegal characters in their file names.

However what is important is how to discover your specific issue because the errors from the Android Asset and Packaging Tool do not show up in the Error List tab in Visual Studio. I had to set the build output verbosity to diagnostic and then search for Task "Aapt". After locating the aapt section, I found the information that allowed me to locate and fix my error at the bottom of the section. I've included it the section of the log:

Executing package -f -m -M C:\Users\billm\AppData\Local\Temp\2xfnjt4r.kaj\manifest\AndroidManifest.xml -J C:\Users\billm\AppData\Local\Temp\2xfnjt4r.kaj ...    
    res\drawable\keyboard-backspace-long.png: Invalid file name: must contain only [a-z0-9_.] (TaskId:113)
    res\drawable\keyboard-backspace-long.png: Invalid file name: must contain only [a-z0-9_.] (TaskId:113)
    res\drawable\keyboard-backspace-xlong.png: Invalid file name: must contain only [a-z0-9_.] (TaskId:113)
    res\drawable\keyboard-backspace-xlong.png: Invalid file name: must contain only [a-z0-9_.] (TaskId:113)
    res\drawable\keyboard-backspace.png: Invalid file name: must contain only [a-z0-9_.] (TaskId:113)
    res\drawable\keyboard-button.png: Invalid file name: must contain only [a-z0-9_.] (TaskId:113)
    Done executing task "Aapt". (TaskId:113)
bmacadam
  • 184
  • 4
0

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

ROHIT MANDALAPU
  • 428
  • 4
  • 16
0

For me this was linked to the error:

"aapt.exe" exited with Code 1.

The cause was a file containing a hyphen or space in my project, which stopped Resources.Designer.cs updating.

In my case the reason the file existed was me creating a backup by copying of it in the solution, which caused it to copy from my_xml_file.xml to my_xml_file - Copy.xml.

SharpC
  • 5,368
  • 3
  • 37
  • 36
0

Not sure if this is the place to put this answer, but I thought I will share this, specifically for VS 2017 users.

If you updated Xamarin Android with version 8.3.0.19 or Visual Studio 2017 to version 15.7.2, You will have to set the property CustomTool of the resource to MSBuild:UpdateGeneratedFiles

Select the resource in the solution explorer, hit f4/right-click and select Properties from the context menu, and set the property CustomTool to MSBuild:UpdateGeneratedFiles. Clean+Build or Rebuild the project and you should be able to see the values updated in Resources.Designer.cs

Ram Iyer
  • 1,313
  • 19
  • 23
-2

if Xamarin resource.designer is not updating one easy solution is to:

  1. Create a new project
  2. Delete the Main axml file and the MainActivity.cs
  3. Add new file that is new layout and the activity.

Once you have generated your axml make sure to save before you begin to code in your new activity.

Hope this will help someone

Diligent Key Presser
  • 3,703
  • 4
  • 23
  • 33