【问题标题】:Error when trying to build Xamarin.Android after VS 2019 updateVS 2019 更新后尝试构建 Xamarin.Android 时出错
【发布时间】:2019-10-24 18:18:37
【问题描述】:

我有一个以前可以正常工作的 Xamarin.Forms 应用,但在从 Visual Studio 2017 更新到 2019 后,我得到了一个尝试构建解决方案时 Xamarin.Android 中的异常。我没有更改我的代码中的任何内容。我得到的例外是:

   Error The "GenerateResourceDesigner" task failed unexpectedly.
   System.Xml.XmlException: '.', hexadecimal value 0x00, is an invalid character. Line 1, position 1.
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)
   at System.Xml.XmlTextReaderImpl.ThrowInvalidChar(Char[] data, Int32 length, Int32 invCharPos)
   at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
   at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
   at System.Xml.XmlTextReaderImpl.Read()
   at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
   at System.Xml.Linq.XDocument.Load(String uri, LoadOptions options)
   at Xamarin.Android.Tasks.ManagedResourceParser.Parse(String resourceDirectory, IEnumerable`1 additionalResourceDirectories, Boolean isApp, Dictionary`2 resourceMap)
   at Xamarin.Android.Tasks.GenerateResourceDesigner.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() EventApp                

我已经尝试了所有可能的方法,例如卸载和重新安装 Visual Studio 2019。清除 binobj 文件夹,但似乎没有任何效果。

有谁知道我该如何解决这个问题?

【问题讨论】:

    标签: visual-studio xamarin xamarin.forms xamarin.android visual-studio-2019


    【解决方案1】:

    您是否更新了所有 NuGet 包?检查所有依赖项?更新到 VS 16.3.5?虽然没有遇到同样的错误,但我在使用最新的 VS 和 XF 以及 Google Ads 时遇到了问题。另一个对我没有帮助但对其他人有所帮助的建议是添加

    android:targetSdkVersion="28"
    

    到使用许可标签。 Net Core 版本设置是否正确?

    【讨论】:

    • 是的,所有 Nugest 包都已更新。依赖关系已解决。 VS 更新到 16.3.5。目标 SdkVersion 是“28”。一切都很好,可以在其他电脑上工作,但不是我的。 @斯蒂芬链接
    • Net Core 2.0 版怎么样? 2.1?您的代码中某处是否有 NULL 值?见 1 月 4 日评论 - github.com/xamarin/xamarin-android/issues/2335
    • 用干净的副本替换 Properties.xml。
    【解决方案2】:

    我的问题已解决。这是 Visual Studio 2019 的一些问题。我在 VS 安装程序中单击了修复 Visual Studio,花了一些时间,然后我的问题得到了解决。无论如何感谢您的帮助:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-25
      • 2021-01-26
      • 2023-01-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多