Xamarin Android Java绑定:缺少类(XMLReader)

web*_*o80 8 xamarin.android xamarin java-binding xamarin-binding

当我在Xamarin.Android项目上并使用Java绑定库时,我几乎总是会遇到一些警告.我收到以下警告:

7>BINDINGSGENERATOR : warning BG8800: Unknown parameter type 
System.Xml.XmlReader in method CreateFromXml in managed type Android.Content.Res.ColorStateList.
7>BINDINGSGENERATOR : warning BG8800: Unknown parameter type 
System.Xml.XmlReader in method CreateFromXml in managed type Android.Content.Res.ColorStateList.
7>BINDINGSGENERATOR : warning BG8800: Unknown parameter type 
System.Xml.XmlReader in method ParseBundleExtras in managed type Android.Content.Res.Resources.
7>BINDINGSGENERATOR : warning BG8800: Unknown parameter type 
System.Xml.XmlReader in method CreateFromXml in managed type Android.Graphics.Drawables.Drawable.
7>BINDINGSGENERATOR : warning BG8800: Unknown parameter type 
System.Xml.XmlReader in method CreateFromXml in managed type Android.Graphics.Drawables.Drawable.
7>BINDINGSGENERATOR : warning BG8800: Unknown parameter type 
System.Xml.XmlReader in method CreateFromXmlInner in managed type Android.Graphics.Drawables.Drawable.
7>BINDINGSGENERATOR : warning BG8800: Unknown parameter type 
System.Xml.XmlReader in method CreateFromXmlInner in managed type Android.Graphics.Drawables.Drawable.
7>BINDINGSGENERATOR : warning BG8800: Unknown parameter type 
System.Xml.XmlReader in method Inflate in managed type Android.Graphics.Drawables.Drawable.
7>BINDINGSGENERATOR : warning BG8800: Unknown parameter type 
System.Xml.XmlReader in method Inflate in managed type Android.Graphics.Drawables.Drawable.
7>BINDINGSGENERATOR : warning BG8800: Unknown parameter type 
System.Xml.XmlReader in method ParseIntent in managed type Android.Content.Intent.
7>BINDINGSGENERATOR : warning BG8800: Unknown parameter type System.Xml.XmlReader in method ReadFromXml in managed type Android.Content.IntentFilter.
Run Code Online (Sandbox Code Playgroud)

我的第一个想法是它缺少System.XML.XMLReader NuGet依赖项,但没有任何意义.我添加了依赖项,但没有用.

后来,查看代码(例如android.content.Intent),我意识到在解析所需的类时它会出错.它不是System.XML .Net框架,而是来自Android Framework的XMLReader类.

任何关于将绑定过程指向正确方向的想法,明确地说明要选择什么类?一些metadata.xml规则?谢谢

编辑:我正在尝试这个:

<attr path="/api/package[@name='android.content.res']/class[@name='Resources']/method[@name='parseBundleExtras']/parameter[0]"
    name="type">android.content.res.XmlResourceParser</attr>
Run Code Online (Sandbox Code Playgroud)

这里可以看出,但解析器找不到任何东西,即使使用不太细粒度的查询:

Metadata.xml(15, 4) warning BG8A04: <attr path="/api/package[@name='android.content.res']/class[@name='Resources']"/> matched no nodes. Seems that I can't make that metadata changes in Android framework directly?
Run Code Online (Sandbox Code Playgroud)

Eri*_*Liu 6

获取正确的组件

  1. 解决方案资源管理器中,右键单击“ 引用”
  2. 选择添加引用...
  3. 选择装配标签

您只需要System.Xml

  1. 然后找到的System.Xml组件选项卡
  2. 选择它
  3. 确定按钮

相对于Visual Studio文件夹,最常见的程序集路径:

...\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Xml.dll
Run Code Online (Sandbox Code Playgroud)

如果它显示多个具有相同名称的程序集,请放心,您可以选择其中的任何一个。不要使用GAC或nuget软件包。始终查找与您的项目类型相对应的程序集,该程序集始终是“首选项管理器”中的“程序集” 选项卡

尝试在修复之后进行构建之前,请清洁项目或进行清洁的构建