Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

does not implement interface member 'IComparable.CompareTo(Object)'

I have an .aar file of android. I am trying to use it in my xamarin.android app. I followed the steps from the given in the link https://developer.xamarin.com/guides/android/advanced_topics/binding-a-java-library/binding-an-aar/

but when I am trying to build my library I am getting following error

"does not implement interface member 'IComparable.CompareTo(Object)'"

I found some solution for it where it is mentioned that in metadata.xml we need to add some attribute. so I added the following line there

path="/api/package[@name='com.logicjunction.ljindoorandroidsdk']/class[@name='FloorPlanBeaconsMapping']/implements[@name='java.lang.Comparable']" 

name="type">java.lang.Comparable>

But still getting same error. How I can fix this?

like image 728
anand Avatar asked Sep 21 '17 07:09

anand


2 Answers

Getting the error when build the library without interface implementation IComparable.CompareTo:

The error'

To resolve the issue, need create at "Additions" folder a partial class of the library class that requires interface member implementation 'IComparable.CompareTo(Object)', like below:

partial class with interface IComparable

The namespace should be the same like at binding library, in this case, it is: "Hirondelle.Date4j".

using Java.Lang;
namespace Hirondelle.Date4j
{
    public partial class DateTime : Object, IComparable
    {
        int IComparable.CompareTo(Object obj)
        {
            return CompareTo((DateTime)obj);
        }
    }
}

Then the library should be built with success.

like image 187
Polyariz Avatar answered Oct 01 '22 13:10

Polyariz


So I had the same problem which I could solve it by helping the compiler in adding those lines in Metada.xml (Transforms folder) :

<add-node path="/api/package[@name='<JAVA_PACKAGE_NAME>']/class[@name='<CLASS_NAME>']">
    <method name="compareTo" return="int" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public">
        <parameter name="p0" type="java.lang.Object" />
    </method>
</add-node>
like image 31
Damiii Avatar answered Oct 01 '22 13:10

Damiii