gpt4 book ai didi

java - Xamarin java绑定(bind)库编译错误

转载 作者:行者123 更新时间:2023-11-30 02:22:23 26 4
gpt4 key购买 nike

我有一个使用 Android 库的 Android 应用程序 (Java)。一切正常,但我需要将此应用程序包装到 Xamarin 应用程序中。所以我决定将此应用程序转换为第二个 Android 库。我创建了我的 Xamarin Android 应用程序和一个 Android Java 绑定(bind)库项目,我在其中将两个 .aar 文件添加到“Jars”文件夹。

当我尝试编译这个绑定(bind)项目时,问题就来了。我收到很多这样的错误:

/.../obj/Release/generated/src/Com.Google.Common.Util.Concurrent.ForwardingListenableFuture.cs(17,17): Error CS0102: The type `Com.Google.Common.Util.Concurrent.ForwardingListenableFutureInvoker' already contains a definition for `id_delegate' (CS0102)

当我打开生成的 ForwardingListenableFuture.cs 文件时,会出现以下代码:

[global::Android.Runtime.Register ("com/google/common/util/concurrent/ForwardingListenableFuture", DoNotGenerateAcw=true)]
internal partial class ForwardingListenableFutureInvoker : ForwardingListenableFuture, global::Com.Google.Common.Util.Concurrent.IListenableFuture {

public ForwardingListenableFutureInvoker (IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer) {}

protected override global::System.Type ThresholdType {
get { return typeof (ForwardingListenableFutureInvoker); }
}

static IntPtr id_delegate;
// Metadata.xml XPath method reference: path="/api/package[@name='com.google.common.util.concurrent']/class[@name='ForwardingListenableFuture']/method[@name='delegate' and count(parameter)=0]"
[Register ("delegate", "()Lcom/google/common/util/concurrent/ListenableFuture;", "GetDelegateHandler")]
protected override global::Com.Google.Common.Util.Concurrent.IListenableFuture Delegate ()
{
if (id_delegate == IntPtr.Zero)
id_delegate = JNIEnv.GetMethodID (class_ref, "delegate", "()Lcom/google/common/util/concurrent/ListenableFuture;");
return global::Java.Lang.Object.GetObject<global::Com.Google.Common.Util.Concurrent.IListenableFuture> (JNIEnv.CallObjectMethod (Handle, id_delegate), JniHandleOwnership.TransferLocalRef);
}

static IntPtr id_delegate;
// Metadata.xml XPath method reference: path="/api/package[@name='com.google.common.util.concurrent']/class[@name='ForwardingFuture']/method[@name='delegate' and count(parameter)=0]"
[Register ("delegate", "()Ljava/util/concurrent/Future;", "GetDelegateHandler")]
protected override global::Java.Util.Concurrent.IFuture Delegate ()
{
if (id_delegate == IntPtr.Zero)
id_delegate = JNIEnv.GetMethodID (class_ref, "delegate", "()Ljava/util/concurrent/Future;");
return global::Java.Lang.Object.GetObject<global::Java.Util.Concurrent.IFuture> (JNIEnv.CallObjectMethod (Handle, id_delegate), JniHandleOwnership.TransferLocalRef);
}

static IntPtr id_delegate;
// Metadata.xml XPath method reference: path="/api/package[@name='com.google.common.collect']/class[@name='ForwardingObject']/method[@name='delegate' and count(parameter)=0]"
[Register ("delegate", "()Ljava/lang/Object;", "GetDelegateHandler")]
protected override global::Java.Lang.Object Delegate ()
{
if (id_delegate == IntPtr.Zero)
id_delegate = JNIEnv.GetMethodID (class_ref, "delegate", "()Ljava/lang/Object;");
return global::Java.Lang.Object.GetObject<global::Java.Lang.Object> (JNIEnv.CallObjectMethod (Handle, id_delegate), JniHandleOwnership.TransferLocalRef);
}

}

确实,“id_delegate”是重复的..

我也有与第一个 .aar(不是应用程序)相关的警告:

/../JARTOXML: Warning J2X9001: Couldn't load class com/company/project/controllers/activities/MenuActivity : java.lang.NoClassDefFoundError: android/support/v4/app/FragmentActivity (J2X9001)

最佳答案

好的,我通过向 Metadata.xml 添加 remove-node 语句解决了错误的第一部分。

对于第二部分,添加对 Xamarin.Android.Support.v4 的引用解决了问题。

关于java - Xamarin java绑定(bind)库编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28296658/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com