8
votes

I am trying Android binding library and I am encountering the below error -

'ReaderCollectionImpl' does not implement inherited abstract member 'AbstractList.Get(int)'

and the below function is generated in my class

public virtual unsafe global::Com.Digitalpersona.Uareu.IReader Get (int n)
{
}

When I try to change the keyword from virtual to override

public override unsafe global::Com.Digitalpersona.Uareu.IReader Get (int n)
{
}

I get this error -

'ReaderCollectionImpl.Get(int)': return type must be 'Object' to match overridden member 'AbstractList.Get(int)'

I cannot change my return type. I also tried using the new keyword however it didn't help me out.

The class looks like this in Java native code -

public class ReaderCollectionImpl extends AbstractList<Reader> implements ReaderCollection
{
}

While converting it in C# it changes to -

public partial class ReaderCollectionImpl : global::Java.Util.AbstractList 
{
}

My guess is Java.Util.AbstractList does not have generics, that might be the issue here?

1
May I know if you have found the solution to this issue?TPG
You have a link for the jar you are trying to bind?shanranm

1 Answers

1
votes

After decompile the dpuareu.jar and look into the original code, I managed to get it compiled without issue by adding these lines in Metadata.xml.

 <attr path="/api/package[@name='com.digitalpersona.uareu.dpfpdd']/class[@name='ReaderCollectionImpl']/ method[@name='get']" name="managedReturn">Java.Lang.Object</attr>
 <attr path="/api/package[@name='com.digitalpersona.uareu.dpfpdd']/class[@name='ReaderCollectionImpl.ReaderImpl']" name="visibility">public</attr>

The next step is to add all the "so" into the project, right click them and select the "Build Action" to "EmbeddedReferenceJar".

enter image description here

With these setup, I'm able to add reference of the DLL to my Xamarin.Android project and call this line without error. I can even call the GetName() below and get the name of the connected scanner. This should serve as the starting point for further development.

    ReaderCollectionImpl readerCollection;

    public ReaderCollectionImpl GetReaders()
    {
        try
        {
            readerCollection = (ReaderCollectionImpl)UareUGlobal.GetReaderCollection(Android.App.Application.Context);
            readerCollection.GetReaders();                

            return readerCollection;
        }
        catch(UareUException ex)
        {
            throw ex;
        }
        catch(Exception ex)
        {
            throw ex;
        }
    }

    public int GetSize()
    {
        return readerCollection.Size();
    }

    public string GetName()
    {
        return (readerCollection.Get(0) as ReaderCollectionImpl.ReaderImpl).Description.Name;
    }