在Xamarin中麻烦绑定Jar库

时间:2016-05-27 17:33:32

标签: android xamarin

在绑定我的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或命名空间的问题吗?有没有办法解决这些错误?感谢您的帮助!

1 个答案:

答案 0 :(得分:3)

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

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

对于您的其他问题,您可以通过<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

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