Xamarin Android绑定库-未在DigitalPersona UareU JAR中实现继承的抽象成员

Zer*_*ro4 7 c# android xamarin digital-persona-sdk

我正在尝试使用Android绑定库,但遇到以下错误-

'ReaderCollectionImpl'未实现继承的抽象成员'AbstractList.Get(int)'

并且下面的函数在我的班级中生成

public virtual unsafe global::Com.Digitalpersona.Uareu.IReader Get (int n)
{
}
Run Code Online (Sandbox Code Playgroud)

当我尝试将关键字从虚拟更改为覆盖时

public override unsafe global::Com.Digitalpersona.Uareu.IReader Get (int n)
{
}
Run Code Online (Sandbox Code Playgroud)

我收到此错误-

'ReaderCollectionImpl.Get(int)':返回类型必须为'Object'以匹配重写的成员'AbstractList.Get(int)'

我无法更改退货类型。我也尝试使用new关键字,但是它没有帮助我。

该类在Java本机代码中看起来像这样-

public class ReaderCollectionImpl extends AbstractList<Reader> implements ReaderCollection
{
}
Run Code Online (Sandbox Code Playgroud)

在C#中将其转换为-

public partial class ReaderCollectionImpl : global::Java.Util.AbstractList 
{
}
Run Code Online (Sandbox Code Playgroud)

我的猜测是Java.Util.AbstractList没有泛型,这可能是这里的问题吗?

tea*_*eng 1

反编译 dpuareu.jar 并查看原始代码后,我通过在 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>
Run Code Online (Sandbox Code Playgroud)

下一步是将所有“so”添加到项目中,右键单击它们并选择“Build Action”到“EmbeddedReferenceJar”。

在此输入图像描述

通过这些设置,我可以将 DLL 的引用添加到我的 Xamarin.Android 项目中,并调用此行而不会出现错误。我什至可以调用下面的 GetName() 并获取连接的扫描仪的名称。这应该作为进一步发展的起点。

    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;
    }
Run Code Online (Sandbox Code Playgroud)