Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin Android Binding Library - does not implement inherited abstract member in DigitalPersona UareU JAR

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?

like image 890
Zero4 Avatar asked Jul 31 '18 11:07

Zero4


1 Answers

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;
    }
like image 105
TPG Avatar answered Nov 16 '22 16:11

TPG