I'm trying to embed some jars from a native project into my Xamarin Android app, and I have hit two separate (but I suspect related) problems:
- One of the files in the package is jna-4.2.0.jar. When I try to build the binding project on its own, I get this error:
The type or namespace name 'ICallback' does not exist in the namespace 'Com.Sun.Jna' (are you missing an assembly reference?)
The generated code is as follows:
[Register ("getCallback", "(Ljava/lang/Class;Lcom/sun/jna/Pointer;)Lcom/sun/jna/Callback;", "")]
public static unsafe global::Com.Sun.Jna.ICallback GetCallback (global::Java.Lang.Class type, global::Com.Sun.Jna.Pointer p)
{
if (id_getCallback_Ljava_lang_Class_Lcom_sun_jna_Pointer_ == IntPtr.Zero)
id_getCallback_Ljava_lang_Class_Lcom_sun_jna_Pointer_ = JNIEnv.GetStaticMethodID (class_ref, "getCallback", "(Ljava/lang/Class;Lcom/sun/jna/Pointer;)Lcom/sun/jna/Callback;");
try {
JValue* __args = stackalloc JValue [2];
__args [0] = new JValue (type);
__args [1] = new JValue (p);
global::Com.Sun.Jna.ICallback __ret = global::Java.Lang.Object.GetObject<global::Com.Sun.Jna.ICallback> (JNIEnv.CallStaticObjectMethod (class_ref, id_getCallback_Ljava_lang_Class_Lcom_sun_jna_Pointer_, __args), JniHandleOwnership.TransferLocalRef);
return __ret;
} finally {
}
}
I have also tried downloading the latest version, jna-4.4.0.jar, from https://github.com/java-native-access/jna, but that generates the same error.
- The library I'm using generates this error:
'Version' does not implement interface member 'IComparable.CompareTo(Object)'
I have tried to solve this issue, following the Xamarin documentation, and using the comments in the generated cs
files, by adding this line to the metadata.xml
file in my bindings project:
<attr path="/api/package[@name='com.innovatrics.iface']/class[@name='Version']/method[@name='compareTo'
and count(parameter)=1
and parameter[1][@type='com.innovatrics.iface.Version']]"
name="managedType">Java.Lang.Object</attr>
but this seems to have had no effect at all.