在 Xamarin 中绑定 Jar 库时遇到问题 [英] Trouble Binding Jar Library In Xamarin

查看:21
本文介绍了在 Xamarin 中绑定 Jar 库时遇到问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

While Binding my jar files I keep getting this error in multiple classes:

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

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

Along with a few other errors such as:

 ‘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 的 jars 或命名空间的问题吗?有没有办法修复这些错误?提前感谢您的帮助!

Could this be an issue with the jars or the namespaces for native android? Is there a way to fix these errors? Thank you for the help in advance!

推荐答案

我有一个通用指南,可能在某些方面有所帮助:

I have a general guide that might help in some areas:

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

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

I believe your current scenario can be fixed via the following:

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

Ideally you need to change the managedType to 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

对于您的其他问题,您可以通过

For your other issue, you can remove the node via <remove-node>

您可以执行以下操作:

<!-- 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

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

这篇关于在 Xamarin 中绑定 Jar 库时遇到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆