java.interop icon indicating copy to clipboard operation
java.interop copied to clipboard

can use use android binding?

Open ljzj2 opened this issue 4 months ago • 5 comments

I am using android binding . I want to get dll from '.aar' which is 'zxing-android-embeded.aar'

in Debug mode I can get dll but there is nothing in dll in Release mode there is two error :

Size does not implement member 'IComparable.CompareTo(Object)'

but I can see that it have implemented it.

[Register ("compareTo", "(Lcom/journeyapps/barcodescanner/Size;)I", "GetCompareTo_Lcom_journeyapps_barcodescanner_Size_Handler")]
public virtual unsafe int CompareTo (global::Com.Journeyapps.Barcodescanner.Size other)
{
	const string __id = "compareTo.(Lcom/journeyapps/barcodescanner/Size;)I";
	try {
		JniArgumentValue* __args = stackalloc JniArgumentValue [1];
		__args [0] = new JniArgumentValue ((other == null) ? IntPtr.Zero : ((global::Java.Lang.Object) other).Handle);
		var __rm = _members.InstanceMethods.InvokeVirtualInt32Method (__id, this, __args);
		return __rm;
	} finally {
		global::System.GC.KeepAlive (other);
	}
}

why?

ljzj2 avatar Aug 24 '25 03:08 ljzj2

It feels like there is a Java method named CompareTo that conflicts with what .NET expects.

We have some general troubleshooting docs for bindings at:

  • https://github.com/dotnet/java-interop/wiki/Troubleshooting-Android-Bindings-Issues
  • https://github.com/dotnet/android-libraries/blob/main/docs/development-tips.md#troubleshooting

jonathanpeppers avatar Aug 25 '25 21:08 jonathanpeppers

thank you for your reply but I think it is not that you said.

since there is another same error:

`protected virtual unsafe global::Com.Journeyapps.Barcodescanner.Camera.CameraThread? CameraThread {
	// Metadata.xml XPath method reference: path="/api/package[@name='com.journeyapps.barcodescanner.camera']/class[@name='CameraInstance']/method[@name='getCameraThread' and count(parameter)=0]"
	[Register ("getCameraThread", "()Lcom/journeyapps/barcodescanner/camera/CameraThread;", "GetGetCameraThreadHandler")]
	get {
		const string __id = "getCameraThread.()Lcom/journeyapps/barcodescanner/camera/CameraThread;";
		try {
			var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, null);
			return global::Java.Lang.Object.GetObject<global::Com.Journeyapps.Barcodescanner.Camera.CameraThread> (__rm.Handle, JniHandleOwnership.TransferLocalRef);
		} finally {
		}
	}
}`

and when I open it there is:

CS1503 parameter 1 can not convert from “Com.Journeyapps.Barcodescanner.Camera.CameraThread?” To “Android.Runtime.IJavaObject?”

there is no CameraThread in .net right? so there is no conflict. and I have rename the CompareTo it is not work.

ljzj2 avatar Aug 26 '25 03:08 ljzj2

I would review the docs above for related cases.

From your example, I don't see what line CS1503 is referring to.

jonathanpeppers avatar Aug 26 '25 19:08 jonathanpeppers

for CS1503 is this line: static IntPtr n_GetCameraThread (IntPtr jnienv, IntPtr native__this) { var __this = global::Java.Lang.Object.GetObject<global::Com.Journeyapps.Barcodescanner.Camera.CameraInstance> (jnienv, native__this, JniHandleOwnership.DoNotTransfer)!; return JNIEnv.ToLocalJniHandle (__this.CameraThread); }

what do you suggest me to do now?

ljzj2 avatar Aug 27 '25 00:08 ljzj2

when I want to remove the node of Size there will be error too. Size does not implement member IComparable.CompareTo(Object)

and there will be another new error

Image

ljzj2 avatar Aug 27 '25 00:08 ljzj2