更新Visual Studio后,Xamarin Android生成报错

这两天想用一下Xamarin,随手新建了一个Xamarin.Form的项目,在编译的时候报了如下错误:

 error XARLC7000: System.Xml.XmlException: 给定编码中的字符无效。 第 1 行,位置 40。
   在 System.Xml.XmlTextReaderImpl.Throw(Exception e)
   在 System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
   在 System.Xml.XmlTextReaderImpl.InvalidCharRecovery(Int32& bytesCount, Int32& charsCount)
   在 System.Xml.XmlTextReaderImpl.GetChars(Int32 maxCharsCount)
   在 System.Xml.XmlTextReaderImpl.ReadData()
   在 System.Xml.XmlTextReaderImpl.ParseText(Int32& startPos, Int32& endPos, Int32& outOrChars)
   在 System.Xml.XmlTextReaderImpl.FinishPartialValue()
   在 System.Xml.XmlTextReaderImpl.get_Value()
   在 System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r)
   在 System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r, LoadOptions o)
   在 System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
   在 System.Xml.Linq.XDocument.Load(String uri, LoadOptions options)
   在 Xamarin.Android.Tasks.ReadLibraryProjectImportsCache.RunTask()
   在 Xamarin.Android.Tasks.AndroidTask.Execute()    App2.Android            

然后历经了各种搜索,删除重装Android SDK,卸载重装Xamarin,都没解决这个问题。
最后打开小飞机,上谷歌搜错误,只有一条记录...
20200524163942.png
搜索结果指向了一个网页 https://developercommunity.visualstudio.com/content/problem/1039028/error-after-updating-visual-studio.html

问题原因是因为vs升级到了最新的16.6.0,降级到16.5.5就可以解决问题了。

怎么降级?看这里 https://docs.microsoft.com/en-us/visualstudio/releases/2019/history

不想降级?那就用第二种解决方法

解决此问题的一种可能的临时方法是将"编码.默认"设置为 UTF-8 系统。

限制: 这可能会导致其他非 Unicode 软件的兼容性问题。

打开控制面板。
单击"更改日期、时间或数字格式"。
单击"管理"选项卡。
20200528190316.png
在"非 Unicode 程序的语言"部分下,单击"更改系统区域设置..."。
选择Beta:使用 Unicode UTF-8 进行全球语言支持。
20200528190303.png
重新启动系统。
参考 https://developercommunity.visualstudio.com/content/problem/955972/the-calltarget-task-returned-false-but-did-not-log.html

上一篇‡: 解决Windows下Docker Desktop 总是 kubernetes is starting...

下一篇‡: 微信分身多开无法打开小程序和公众号文章的解决方法

最近回复