Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin Android Java Binding: Missing class (XMLReader)

I'm facing some warnings nearly always when I'm on a Xamarin.Android project, and using a Java Binding Library. I obtain the following warnings:

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.

My first thought was that it was missing the System.XML.XMLReader NuGet dependency, but it had no sense. I added the dependency, and didn't work.

Later, viewing the code (e.g. android.content.Intent), I realized that somehow it's getting wrong when resolving the required class. It's not the System.XML .Net framework one, but XMLReader class from Android Framework.

Any idea on pointing the binding proccess to the right direction, telling explicitely what class to pick? Some metadata.xml rule? Thanks

EDIT: I'm trying with this:

<attr path="/api/package[@name='android.content.res']/class[@name='Resources']/method[@name='parseBundleExtras']/parameter[0]"
    name="type">android.content.res.XmlResourceParser</attr>

as can be seen here, but parser is not finding anything, even using a less fine-grained query:

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?
like image 342
webo80 Avatar asked May 17 '18 09:05

webo80


1 Answers

To get correct assemblies

  1. In Solution Explorer right-click References
  2. Select Add References...
  3. Select Assemblies tab

All you need is System.Xml

  1. Scroll down and find System.Xml in Assemblies tab
  2. Select it
  3. Press Ok button

Most common path to the assembly relatively from Visual Studio folder:

...\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Xml.dll

If it shows multiple assemblies with same name, don't worry, you can pick any of it. Don't use GAC or nuget package. Always look for Assemblies corresponding to your project type which is always t the Assemblies tab in Preference Manager.

Before attempting to build after the fix, clean the project or do a clean build.

like image 73
Eric Liu Avatar answered Oct 20 '22 23:10

Eric Liu