绑定aar Visual Studio(Xamarin)

时间:2017-02-03 18:47:36

标签: android visual-studio xamarin xamarin.android aar

我在Visual Studio中使用xamarin并尝试链接文件(java到C#) 我使用库绑定(android)来集成文件,但是对于某些方法,这个过程转换为失败。

错误消息

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

我尝试配置元数据,但无法解决这些错误 有人已经看到了这个问题..你知道如何解决吗?

API xml

<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 个答案:

答案 0 :(得分:0)

您的问题很可能就在这里:

<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...参数。这需要完全匹配接口所期望的内容,如果没有,你需要&#34; dumb&#34;对象类型。

简而言之,您正在使用部分通用支持http://docs.xamarin.com/guides/android/advanced_topics/limitations/#Partial_Java_Generics_Support

你可以做几件事:

  1. 创建故障类的部分类并在其中创建覆盖:
  2. 即。

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

    1. 如果您打算完全不使用此课程,请使用<remove-node>删除课程:https://gist.github.com/JonDouglas/dda6d8ace7d071b0e8cb#removing-types
    2. 有很多方法可以在Metadata.xml中修复此问题,但我必须查看示例。理想情况下,您可以更改managedReturnmanagedType甚至argsType