【问题标题】:Xamarin Android Binding Library - does not implement inherited abstract member in DigitalPersona UareU JARXamarin Android 绑定库 - 未在 DigitalPersona UareU JAR 中实现继承的抽象成员
【发布时间】:2023-03-13 15:51:02
【问题描述】:

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

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

下面的函数是在我的类中生成的

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

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

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

我收到此错误 -

'ReaderCollectionImpl.Get(int)':返回类型必须是 'Object' 以匹配被覆盖的成员 'AbstractList.Get(int)'

我无法更改我的返回类型。我也尝试使用 new 关键字,但它并没有帮助我。

Java 原生代码中的类如下所示 -

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

在 C# 中将其转换为 -

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

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

【问题讨论】:

  • 请问您是否找到了解决此问题的方法?
  • 您有您要绑定的 jar 的链接吗?

标签: c# android xamarin digital-persona-sdk


【解决方案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>

下一步是将所有“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;
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多