[android]绑定 aar Visual Studio (Xamarin)

发布时间: 2017/3/19 18:28:57
注意事项: 本文中文内容可能为机器翻译,如要查看英文原文请点击上面连接.

我正与在 Visual Studio 中的 xamarin 和我试着将文件链接 (java 到 C#) 我使用图书馆绑定 ( android ),集成的文件,但对某些方法这 process 转换失败。

错误消息

Class X does not implement inherited abstract member 'AsyncTask.DoInBackground (params Object [])'

我试着配置元数据,但我不能解决这些错误有人已经看见了这一问题。和你知道如何解决??

APIxml

<class abstract="false" deprecated="not deprecated" extends="android.os.AsyncTask" extends-generic-aware="android.os.AsyncTask&lt;java.lang.Object, java.lang.Void, com.ingomoney.ingosdk.android.http.json.response.base.MobileStatusResponse&gt;" final="false" name="ApiCallAsyncTask" static="false" visibility="public">
    <constructor deprecated="not deprecated" final="false" name="ApiCallAsyncTask" static="false" type="com.ingomoney.ingosdk.android.http.asynctask.ApiCallAsyncTask" visibility="public">
    <parameter name="p0" type="com.ingomoney.ingosdk.android.http.asynctask.callback.BaseApiCallAsyncTaskCallback">
    </parameter>
    <parameter name="p1" type="com.ingomoney.ingosdk.android.http.json.request.base.BaseRequest">
    </parameter>
    <parameter name="p2" type="boolean">
    </parameter>
    <parameter name="p3" type="boolean">
    </parameter>
    </constructor>
<constructor deprecated="not deprecated" final="false" name="ApiCallAsyncTask" static="false" type="com.ingomoney.ingosdk.android.http.asynctask.ApiCallAsyncTask" visibility="public">
<parameter name="p0" type="com.ingomoney.ingosdk.android.http.asynctask.callback.BaseApiCallAsyncTaskCallback">
</parameter>
<parameter name="p1" type="com.ingomoney.ingosdk.android.http.json.request.base.BaseRequest">
</parameter>
<parameter name="p2" type="boolean">
</parameter>
</constructor>
<constructor deprecated="not deprecated" final="false" name="ApiCallAsyncTask" static="false" type="com.ingomoney.ingosdk.android.http.asynctask.ApiCallAsyncTask" visibility="public">
<parameter name="p0" type="com.ingomoney.ingosdk.android.http.asynctask.callback.BaseApiCallAsyncTaskCallback">
</parameter>
<parameter name="p1" type="com.ingomoney.ingosdk.android.http.json.request.base.BaseRequest">
</parameter>
</constructor>
<method abstract="false" deprecated="not deprecated" final="false" name="doInBackground" native="false" return="com.ingomoney.ingosdk.android.http.json.response.base.MobileStatusResponse" static="false" synchronized="false" visibility="protected">
<parameter name="p0" type="java.lang.Object...">
</parameter>
</method>
<method abstract="false" deprecated="not deprecated" final="false" name="onPostExecute" native="false" return="void" static="false" synchronized="false" visibility="protected">
<parameter name="p0" type="com.ingomoney.ingosdk.android.http.json.response.base.MobileStatusResponse">
</parameter>
</method>
<method abstract="false" deprecated="not deprecated" final="false" name="writeDataForRequestObject" native="false" return="void" static="false" synchronized="false" visibility="protected">
<parameter name="p0" type="java.net.HttpURLConnection">
</parameter>
<parameter name="p1" type="java.lang.Object">
</parameter>
<exception name="IOException" type="java.io.IOException">
</exception>
</method>
<field deprecated="not deprecated" final="true" name="LOCK" static="true" transient="false" type="java.lang.Object" type-generic-aware="java.lang.Object" visibility="protected" volatile="false">
</field>
<field deprecated="not deprecated" final="true" name="baseRequest" static="false" transient="false" type="com.ingomoney.ingosdk.android.http.json.request.base.BaseRequest" type-generic-aware="com.ingomoney.ingosdk.android.http.json.request.base.BaseRequest" visibility="protected" volatile="false">
</field>
<field deprecated="not deprecated" final="true" name="blocking" static="false" transient="false" type="boolean" type-generic-aware="boolean" visibility="protected" volatile="false">
</field>
<field deprecated="not deprecated" final="true" name="callback" static="false" transient="false" type="com.ingomoney.ingosdk.android.http.asynctask.callback.BaseApiCallAsyncTaskCallback" type-generic-aware="com.ingomoney.ingosdk.android.http.asynctask.callback.BaseApiCallAsyncTaskCallback" visibility="protected" volatile="false">
</field>
<field deprecated="not deprecated" final="true" name="showDialog" static="false" transient="false" type="boolean" type-generic-aware="boolean" visibility="protected" volatile="false">
</field>
</class>

元数据

<metadata>
  <!--
  This sample removes the class: android.support.v4.content.AsyncTaskLoader.LoadTask:
  <remove-node path="/api/package[@name='android.support.v4.content']/class[@name='AsyncTaskLoader.LoadTask']" />

  This sample removes the method: android.support.v4.content.CursorLoader.loadInBackground:
  <remove-node path="/api/package[@name='android.support.v4.content']/class[@name='CursorLoader']/method[@name='loadInBackground']" />
  -->

    <!-- 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) -->
    <remove-node path="/api/package[@name='com.ingomoney.ingosdk.android.http.asynctask']/class[@name='ApiCallAsyncTask']" />
    <remove-node path="/api/package[@name='com.ingomoney.ingosdk.android.http.asynctask']/class[@name='CustomApiCallAsyncTask']" />
    <remove-node path="/api/package[@name='com.ingomoney.ingosdk.android.http.asynctask']/class[@name='ExtractZipFileAsyncTask']" />
    <remove-node path="/api/package[@name='com.ingomoney.ingosdk.android.http.asynctask']/class[@name='GetApplicationPropertiesApiCallAsyncTaskCallback']" />
    <remove-node path="/api/package[@name='com.ingomoney.ingosdk.android.http.asynctask']/class[@name='GetImageBytesAsyncTask']" />
    <remove-node path="/api/package[@name='com.ingomoney.ingosdk.android.http.asynctask']/class[@name='GetRegisteredCardsAsyncTask']" />    
    <remove-node path="/api/package[@name='com.ingomoney.ingosdk.android.asynctask']/class[@name='SavePictureAsyncTask']" />
    <remove-node path="/api/package[@name='com.ingomoney.ingosdk.android.http.asynctask']/class[@name='StoreImageBytesApiCallAsyncTask']" />
    <remove-node path="/api/package[@name='com.ingomoney.ingosdk.android.asynctask']/class[@name='ValidateCheckImagesWithA2iaAsyncTask']" />    
</metadata>

解决方法 1:

您的问题最有可能坐在这里︰

<method abstract="false" deprecated="not deprecated" final="false" name="doInBackground" native="false" return="com.ingomoney.ingosdk.android.http.json.response.base.MobileStatusResponse" static="false" synchronized="false" visibility="protected">
<parameter name="p0" type="java.lang.Object...">
</parameter>
</method>

正如你可以看到这里,方法 doInBackground 返回 com.ingomoney.ingosdk.android.http.json.response.base.MobileStatusResponse 和带有一个参数 java.lang.Object... 。这需要匹配到底什么接口预计,如果它不存在,则需要"哑巴"下来的对象 type

简而言之,你将陷入局部泛型支持, http://docs.xamarin.com/guides/android/advanced_topics/limitations/#Partial_Java_Generics_Support

还有几个你可以做的事情︰

  1. 在故障创建分部类的类和创建内部重写︰

protected override Java.Lang.Object DoInBackground(params Java.Lang.Object[] params){...}

  1. 如果你计划根本不使用此类,使用 <remove-node> 删除类别︰ https://gist.github.com/JonDouglas/dda6d8ace7d071b0e8cb#removing-types

有方法可以解决在此 Metadata.xml ,但我不得不看样。理想情况下,您可能会更改 managedReturnmanagedType ,或甚至 argsType

官方微信
官方QQ群
31647020