简体   繁体   English

Resource.designer.cs 未更新

[英]Resource.designer.cs Not Updating

Computer Specification电脑规格

  • Visual Studio 2015 Enterprise Update 3 Visual Studio 2015 企业更新 3
  • Xamarin 4.2.0.719 Xamarin 4.2.0.719
  • Xamarin.Android 7.0.1.6 Xamarin.Android 7.0.1.6
  • Xamarin.iOS 10.2.0.4 Xamarin.iOS 10.2.0.4

Problem Details问题详情

Resource.designer.cs Not Updating in Xamarin.Droid project. Resource.designer.cs 未在 Xamarin.Droid 项目中更新。

  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将文件重新添加为 Android 资源
  7. Tried to delete the Resources.Designer.cs file试图删除 Resources.Designer.cs 文件

I tried all of the posts below that i might think this is a duplicate post:我尝试了下面的所有帖子,我可能认为这是一个重复的帖子:

Also tried official link from Xamarin:还尝试了 Xamarin 的官方链接:

I tried this one from Codeproject where it says [Solved] But also didn't work for myself:我从 Codeproject 尝试了这个,它说 [已解决] 但对我自己也不起作用:

I had a similar problem where there was an error in a resource file which prevented the resource.designer.cs file from updating.我遇到了类似的问题,资源文件中存在错误,导致 resource.designer.cs 文件无法更新。 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.但是,重要的是如何发现您的特定问题,因为来自 Android 资产和打包工具的错误不会显示在 Visual Studio 的“错误列表”选项卡中。 I had to set the build output verbosity to diagnostic and then search for Task "Aapt".我必须将构建输出详细程度设置为诊断,然后搜索任务“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.找到 aapt 部分后,我在该部分的底部找到了允许我定位和修复错误的信息。 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)

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方法 1:从项目中删除文件并删除 bin 和 obj 文件,然后构建项目它应该像我以前那样工作 100% 如果我遇到同样的问题如果这不起作用总是有另一种选择

method2: close the application ie, visual studio, map to c-> users-> -> AppData (Hidden File) -> delete xamarin file from local and roaming方法2:关闭应用即visual studio,映射到c->用户->->AppData(隐藏文件)->从本地和漫游中删除xamarin文件

For me this was linked to the error:对我来说,这与错误有关:

"aapt.exe" exited with Code 1. “aapt.exe”以代码 1 退出。

The cause was a file containing a hyphen or space in my project, which stopped Resources.Designer.cs updating.原因是我的项目中有一个包含连字符或空格的文件,该文件停止了Resources.Designer.cs更新。

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 .在我的情况下,文件存在的原因是我通过在解决方案中复制它来创建备份,这导致它从my_xml_file.xml复制到my_xml_file - Copy.xml

Not sure if this is the place to put this answer, but I thought I will share this, specifically for VS 2017 users.不确定这是否是放置这个答案的地方,但我想我会分享这个,特别是对于 VS 2017 用户。

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如果您将版本 8.3.0.19 或 Visual Studio 2017 的 Xamarin Android 更新到版本 15.7.2,则必须将资源的属性CustomTool设置为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 .solution explorer资源管理器中选择资源,点击 f4/右键单击并从上下文菜单中选择属性,并将属性CustomTool设置为MSBuild:UpdateGeneratedFiles Clean+Build or Rebuild the project and you should be able to see the values updated in Resources.Designer.cs Clean+Build 或 Rebuild 项目,您应该能够看到 Resources.Designer.cs 中更新的值

if Xamarin resource.designer is not updating one easy solution is to:如果 Xamarin resource.designer 没有更新,一个简单的解决方案是:

  1. Create a new project创建一个新项目
  2. Delete the Main axml file and the MainActivity.cs删除 Main axml 文件和 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.生成 axml 后,请确保在开始在新活动中编码之前进行保存。

Hope this will help someone希望这会帮助某人

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM