Maui Android绑定库错误:未实现继承的抽象成员AsyncTask.DoInBackground(params Object[])

qoefvg9y  于 2023-04-28  发布在  Android
关注(0)|答案(1)|浏览(179)

我想使用Maui Android项目中的.aar文件。
在我创建绑定项目并尝试构建之后,我得到了这个错误:

D:\codeup\Grial\NetEasy.Droid\obj\Debug\net7.0-android\generated\src\Com.Netease.Cloud.Nos.Yidun.Core.UploadTask.cs(10,23,10,33): error CS0534: “UploadTask”  does not implement inherited abstract member 
 “AsyncTask.DoInBackground(params Object[]?)”

使用反编译器,我检查了UploadTask的内容,发现如下:

public class UploadTask extends AsyncTask<Object, Object, CallRet> {
public CallRet doInBackground(Object... params) {
    try {
      this.item.setNetEnv(object1.getNetworkType());
      this.item.setClientIP(Util.getIPAddress());
      this.item.setBucketName(this.bucketName);
      Object object1;
      HttpResult httpResult;
      if ((httpResult = queryLBS((object1 = NetworkType.getNetWorkType(this.context)).getNetworkType())) != null && httpResult.getStatusCode() != 200)
        if (Util.getData(this.context, this.bucketName + "netease_pomelo_nos_server") == null) {
          object1 = this.fileParam;
          String str4 = this.uploadContext;
          int j = httpResult.getStatusCode();
          String str5 = Util.getResultString(httpResult, "requestID");
          String str6 = Util.getResultString(httpResult, "callbackRetMsg");
          return new CallRet(object1, str4, j, str5, str6, httpResult.getMsg().toString(), null);
        }  
      long l1 = System.currentTimeMillis();
      if ((object1 = doUpload(object1.getChunkSize())) == null)
        super(500, new JSONObject(), null); 
      long l2 = System.currentTimeMillis();
      float f = (float)((this.fileSize - this.offset) / 1024.0D / (l1 = l2 - l1) / 1000.0D);
      LogUtil.w(LOGTAG, "upload result:" + object1.getStatusCode() + ", speed:" + f + "KB/S");
      this.item.setUploaderUseTime(l1);
      this.item.setUploaderHttpCode(Util.getHttpCode((HttpResult)object1));
      if (object1.getStatusCode() != 200 && !this.upCancelled)
        Util.setBooleanData(this.context, this.bucketName + "netease_pomelo_nos_lbs_status", false); 
      Object object2 = this.fileParam;
      String str1 = this.uploadContext;
      int i = object1.getStatusCode();
      String str2 = Util.getResultString((HttpResult)object1, "requestID");
      String str3 = Util.getResultString((HttpResult)object1, "callbackRetMsg");
      return new CallRet(object2, str1, i, str2, str3, object1.getMsg().toString(), null);
    } catch (Exception exception) {
      LogUtil.e(LOGTAG, "upload exception", exception);
      Object object = this.fileParam;
      return new CallRet(object, this.uploadContext, 799, "", "", null, exception);
    } finally {
      Util.closeInputStream(this.inputStream);
    } 
  }
}

自动生成的C#代码如下:

// Metadata.xml XPath method reference: path="/api/package[@name='com.netease.cloud.nos.yidun.core']/class[@name='UploadTask']/method[@name='doInBackground' and count(parameter)=1 and parameter[1][@type='java.lang.Object...']]"
        [Register ("doInBackground", "([Ljava/lang/Object;)Lcom/netease/cloud/nos/yidun/core/CallRet;", "GetDoInBackground_arrayLjava_lang_Object_Handler")]
        public virtual unsafe global::Java.Lang.Object? DoInBackground (params global::Java.Lang.Object[]? @params)
        {
            const string __id = "doInBackground.([Ljava/lang/Object;)Lcom/netease/cloud/nos/yidun/core/CallRet;";
            IntPtr native__params = JNIEnv.NewArray (@params);
            try {
                JniArgumentValue* __args = stackalloc JniArgumentValue [1];
                __args [0] = new JniArgumentValue (native__params);
                var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, __args);
                return global::Java.Lang.Object.GetObject<global::Java.Lang.Object> (__rm.Handle, JniHandleOwnership.TransferLocalRef);
            } finally {
                if (@params != null) {
                    JNIEnv.CopyArray (native__params, @params);
                    JNIEnv.DeleteLocalRef (native__params);
                }
                global::System.GC.KeepAlive (@params);
            }
        }

我该怎么弥补

kse8i1jr

kse8i1jr1#

我将此内容添加到metadata.xml并解决了这个问题。

<add-node path="/api/package[@name='com.netease.cloud.nos.yidun.core']">
    <class abstract="false" deprecated="not deprecated" final="false" name="CallRet" static="true" visibility="public" extends="java.lang.Object"></class>
    <class abstract="false" deprecated="not deprecated" final="false" name="UploadTask" static="true" visibility="public" extends="java.lang.Object"></class>
  </add-node>

相关问题