【问题标题】:Trouble Binding Jar Library In Xamarin在 Xamarin 中绑定 Jar 库时遇到问题
【发布时间】:2016-05-28 02:22:40
【问题描述】:

在绑定我的 jar 文件时,我在多个类中不断收到此错误:

Error CS0534: 'path’ does not implement inherited abstract memberAndroid.OS.AsyncTask.DoInBackground(params 
Java.Lang.Object[])' (CS0534)

还有一些其他错误,例如:

 ‘package’.Get(int)' hides inherited abstract member `Java.Util.AbstractList.Get(int)' (CS0533)

`package’: member names cannot be the same as their enclosing type (CS0542)

这可能是原生 android 的 jar 或命名空间的问题吗?有没有办法修复这些错误?提前感谢您的帮助!

【问题讨论】:

    标签: android xamarin


    【解决方案1】:

    我有一个可能在某些方面有所帮助的一般指南:

    https://gist.github.com/JonDouglas/dda6d8ace7d071b0e8cb

    我相信您当前的情况可以通过以下方式解决:

    理想情况下,您需要将managedType 更改为Java.Lang.Object

    <!-- There are also some methods that need to have their generic _parameter_ types simplified to `java.lang.Object`.
             Possible error message: Error CS0115: `SomeMethod(..., T, ...)' is marked as an override but no suitable method found to override (CS0115)
             Possible error message: Error CS0535: `SomeClass' does not implement interface member `SomeMethod(..., Java.Lang.Object,...)' (CS0535)
             Possible error message: Error CS0534: `SomeClass' does not implement inherited abstract member `SomeMethod(..., Java.Lang.Object,...)' (CS0534) -->
        <attr path="/api/package[@name='com.socialize.api']/class[@name='SocializeApi.AsyncAuthenicator']/method[@name='doInBackground' and count(parameter)=1 and parameter[1][@type='com.socialize.api.SocializeRequest']]/parameter[1]" name="managedType">Java.Lang.Object</attr>
        <attr path="/api/package[@name='com.socialize.api']/class[@name='SocializeApi.AsyncGetter']/method[@name='doInBackground' and count(parameter)=1 and parameter[1][@type='com.socialize.api.SocializeRequest']]/parameter[1]" name="managedType">Java.Lang.Object</attr>
        <attr path="/api/package[@name='com.socialize.api']/class[@name='SocializeApi.AsyncPutter']/method[@name='doInBackground' and count(parameter)=1 and parameter[1][@type='com.socialize.api.SocializeRequest']]/parameter[1]" name="managedType">Java.Lang.Object</attr>
    

    来源:https://gist.github.com/brendanzagaeski/9607158#file-metadata-xml-L74-L76

    对于您的其他问题,您可以通过&lt;remove-node&gt;删除节点

    您可以执行以下操作:

    <!-- The bindings generator does not currently handle cases where a subclass provides an abstract override for an
         abstract method. From what I've seen, there is no need to keep abstract overrides of abstract methods in the
         binding, so we can remove them.
         Error message: Error CS0533: `SomeMethodName' hides inherited abstract member `SomeMethodName' (CS0533) -->
    <remove-node path="/api/package[@name='com.socialize.entity']/class[@name='SocializeActionFactory']/method[@name='postFromJSON' and count(parameter)=2 and parameter[1][@type='org.json.JSONObject'] and parameter[2][@type='T']]" />
    <remove-node path="/api/package[@name='com.socialize.entity']/class[@name='SocializeActionFactory']/method[@name='postToJSON' and count(parameter)=2 and parameter[1][@type='T'] and parameter[2][@type='org.json.JSONObject']]" />
    

    来源:https://gist.github.com/brendanzagaeski/9607158#file-metadata-xml-L63-L68

    请注意,您需要根据您的包名和类名调整这些示例。

    【讨论】:

    • 感谢您的反馈!我将这些实现到我的项目元数据中,并且它没有错误地构建。现在,当我在我的 Droid 项目中添加对库的引用并尝试构建应用程序时,我遇到了一个新错误:mandroiderror XA0000: Invalid create-package command: -v --nosign --sdk-dir 关于什么的任何想法这个错误是什么意思?谢谢!
    • 感谢您的指导! Xamarin 绑定令人沮丧,而且文档非常好!
    最近更新 更多