在 Xamarin 中绑定 Java 库时出现错误和警告?
Errors and warnings when Binding a Java Library in Xamarin?
我正在尝试将 SightCall Android SDK 集成到我的 Xamarin 应用程序中。由于 SDK 包含一个 jar 和 .so 文件,我需要将其绑定为 Java 绑定库,然后将其作为参考添加到我的项目中。我按照 Xamarin 网站中给出的创建 Java 绑定项目的步骤进行操作,但在构建之后我收到了 12 个错误和许多警告。 12 个错误如下:
C:\Users\user\Documents\Projects\SightCallBindingLibrary\SightCallBindingLibrary\obj\Debug\generated\src\Net.Rtccloud.Sdk.Event.Meetingpoint.RequestEvent.cs(8,8): Error CS0019: Operator '!=' cannot be applied to operands of type 'Net.Rtccloud.Sdk.Event.Meetingpoint.RequestEvent.Type' and 'System.Type' (CS0019) (SightCallBindingLibrary)
C:\Users\user\Documents\Projects\SightCallBindingLibrary\SightCallBindingLibrary\obj\Debug\generated\src\Net.Rtccloud.Sdk.Event.Meetingpoint.RequestEvent.cs(7,7): Error CS1502: The best overloaded method match for 'Android.Runtime.JNIEnv.StartCreateInstance(System.IntPtr, System.IntPtr, params Android.Runtime.JValue[])' has some invalid arguments (CS1502) (SightCallBindingLibrary)
C:\Users\user\Documents\Projects\SightCallBindingLibrary\SightCallBindingLibrary\obj\Debug\generated\src\Net.Rtccloud.Sdk.Event.Meetingpoint.RequestEvent.cs(59,59): Error CS1503: Argument 1: cannot convert from 'Net.Rtccloud.Sdk.Event.Meetingpoint.RequestEvent.Type' to 'System.IntPtr' (CS1503) (SightCallBindingLibrary)
C:\Users\user\Documents\Projects\SightCallBindingLibrary\SightCallBindingLibrary\obj\Debug\generated\src\Net.Rtccloud.Sdk.Event.Meetingpoint.RequestEvent.cs(71,71): Error CS1503: Argument 2: cannot convert from 'string' to 'System.IntPtr' (CS1503) (SightCallBindingLibrary)
C:\Users\user\Documents\Projects\SightCallBindingLibrary\SightCallBindingLibrary\obj\Debug\generated\src\Net.Rtccloud.Sdk.Event.Meetingpoint.RequestEvent.cs(9,9): Error CS0019: Operator '==' cannot be applied to operands of type 'Net.Rtccloud.Sdk.Event.Meetingpoint.RequestEvent.Type' and 'System.Type' (CS0019) (SightCallBindingLibrary)
C:\Users\user\Documents\Projects\SightCallBindingLibrary\SightCallBindingLibrary\obj\Debug\generated\src\Net.Rtccloud.Sdk.Event.Meetingpoint.RequestEvent.cs(9,9): Error CS0019: Operator '==' cannot be applied to operands of type 'Net.Rtccloud.Sdk.Event.Meetingpoint.RequestEvent.Type' and 'System.Type' (CS0019) (SightCallBindingLibrary)
C:\Users\user\Documents\Projects\SightCallBindingLibrary\SightCallBindingLibrary\obj\Debug\generated\src\Net.Rtccloud.Sdk.Event.Meetingpoint.RequestEvent.cs(8,8): Error CS0019: Operator '==' cannot be applied to operands of type 'Net.Rtccloud.Sdk.Event.Meetingpoint.RequestEvent.Type' and 'System.Type' (CS0019) (SightCallBindingLibrary)
C:\Users\user\Documents\Projects\SightCallBindingLibrary\SightCallBindingLibrary\obj\Debug\generated\src\Net.Rtccloud.Sdk.Event.Meetingpoint.StatusEvent.cs(8,8): Error CS0019: Operator '!=' cannot be applied to operands of type 'Net.Rtccloud.Sdk.Event.Meetingpoint.StatusEvent.Type' and 'System.Type' (CS0019) (SightCallBindingLibrary)
C:\Users\user\Documents\Projects\SightCallBindingLibrary\SightCallBindingLibrary\obj\Debug\generated\src\Net.Rtccloud.Sdk.Event.Meetingpoint.StatusEvent.cs(7,7): Error CS1502: The best overloaded method match for 'Android.Runtime.JNIEnv.StartCreateInstance(System.IntPtr, System.IntPtr, params Android.Runtime.JValue[])' has some invalid arguments (CS1502) (SightCallBindingLibrary)
C:\Users\user\Documents\Projects\SightCallBindingLibrary\SightCallBindingLibrary\obj\Debug\generated\src\Net.Rtccloud.Sdk.Event.Meetingpoint.StatusEvent.cs(59,59): Error CS1503: Argument 1: cannot convert from 'Net.Rtccloud.Sdk.Event.Meetingpoint.StatusEvent.Type' to 'System.IntPtr' (CS1503) (SightCallBindingLibrary)
C:\Users\user\Documents\Projects\SightCallBindingLibrary\SightCallBindingLibrary\obj\Debug\generated\src\Net.Rtccloud.Sdk.Event.Meetingpoint.StatusEvent.cs(71,71): Error CS1503: Argument 2: cannot convert from 'string' to 'System.IntPtr' (CS1503) (SightCallBindingLibrary)
C:\Users\user\Documents\Projects\SightCallBindingLibrary\SightCallBindingLibrary\obj\Debug\generated\src\Net.Rtccloud.Sdk.Event.Meetingpoint.StatusEvent.cs(8,8): Error CS0019: Operator '==' cannot be applied to operands of type 'Net.Rtccloud.Sdk.Event.Meetingpoint.StatusEvent.Type' and 'System.Type' (CS0019) (SightCallBindingLibrary)
能否告诉我如何解决上述问题?
编辑
<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']" />
-->
<!-- <remove-node path="/api/package[@name='Net.Rtccloud.Sdk.Event.Meetingpoint']/class[@name='RequestEvent.Type']" />-->
<!-- <remove-node path="/api/package[@name='Net.Rtccloud.Sdk.Event.Meetingpoint.RequestEvent']"/>-->
<!-- <remove-node path="/api/package[@name='Net.Rtccloud.Sdk.Event.Meetingpoint.MeetingPointEvent']/class[@name='RequestEvent.Type']"/>-->
</metadata>
我已经注释掉了我尝试过的各种方法,因为我收到一条警告,指出删除的节点路径不匹配任何节点。
如 here 所述,绑定应遵守 java 程序包命名约定(小写)。
这里应该是:
net.rtccloud.sdk.event.meetingpoint.RequestEvent
而不是
Net.Rtccloud.Sdk.Event.Meetingpoint.RequestEvent
我正在尝试将 SightCall Android SDK 集成到我的 Xamarin 应用程序中。由于 SDK 包含一个 jar 和 .so 文件,我需要将其绑定为 Java 绑定库,然后将其作为参考添加到我的项目中。我按照 Xamarin 网站中给出的创建 Java 绑定项目的步骤进行操作,但在构建之后我收到了 12 个错误和许多警告。 12 个错误如下:
C:\Users\user\Documents\Projects\SightCallBindingLibrary\SightCallBindingLibrary\obj\Debug\generated\src\Net.Rtccloud.Sdk.Event.Meetingpoint.RequestEvent.cs(8,8): Error CS0019: Operator '!=' cannot be applied to operands of type 'Net.Rtccloud.Sdk.Event.Meetingpoint.RequestEvent.Type' and 'System.Type' (CS0019) (SightCallBindingLibrary)
C:\Users\user\Documents\Projects\SightCallBindingLibrary\SightCallBindingLibrary\obj\Debug\generated\src\Net.Rtccloud.Sdk.Event.Meetingpoint.RequestEvent.cs(7,7): Error CS1502: The best overloaded method match for 'Android.Runtime.JNIEnv.StartCreateInstance(System.IntPtr, System.IntPtr, params Android.Runtime.JValue[])' has some invalid arguments (CS1502) (SightCallBindingLibrary)
C:\Users\user\Documents\Projects\SightCallBindingLibrary\SightCallBindingLibrary\obj\Debug\generated\src\Net.Rtccloud.Sdk.Event.Meetingpoint.RequestEvent.cs(59,59): Error CS1503: Argument 1: cannot convert from 'Net.Rtccloud.Sdk.Event.Meetingpoint.RequestEvent.Type' to 'System.IntPtr' (CS1503) (SightCallBindingLibrary)
C:\Users\user\Documents\Projects\SightCallBindingLibrary\SightCallBindingLibrary\obj\Debug\generated\src\Net.Rtccloud.Sdk.Event.Meetingpoint.RequestEvent.cs(71,71): Error CS1503: Argument 2: cannot convert from 'string' to 'System.IntPtr' (CS1503) (SightCallBindingLibrary)
C:\Users\user\Documents\Projects\SightCallBindingLibrary\SightCallBindingLibrary\obj\Debug\generated\src\Net.Rtccloud.Sdk.Event.Meetingpoint.RequestEvent.cs(9,9): Error CS0019: Operator '==' cannot be applied to operands of type 'Net.Rtccloud.Sdk.Event.Meetingpoint.RequestEvent.Type' and 'System.Type' (CS0019) (SightCallBindingLibrary)
C:\Users\user\Documents\Projects\SightCallBindingLibrary\SightCallBindingLibrary\obj\Debug\generated\src\Net.Rtccloud.Sdk.Event.Meetingpoint.RequestEvent.cs(9,9): Error CS0019: Operator '==' cannot be applied to operands of type 'Net.Rtccloud.Sdk.Event.Meetingpoint.RequestEvent.Type' and 'System.Type' (CS0019) (SightCallBindingLibrary)
C:\Users\user\Documents\Projects\SightCallBindingLibrary\SightCallBindingLibrary\obj\Debug\generated\src\Net.Rtccloud.Sdk.Event.Meetingpoint.RequestEvent.cs(8,8): Error CS0019: Operator '==' cannot be applied to operands of type 'Net.Rtccloud.Sdk.Event.Meetingpoint.RequestEvent.Type' and 'System.Type' (CS0019) (SightCallBindingLibrary)
C:\Users\user\Documents\Projects\SightCallBindingLibrary\SightCallBindingLibrary\obj\Debug\generated\src\Net.Rtccloud.Sdk.Event.Meetingpoint.StatusEvent.cs(8,8): Error CS0019: Operator '!=' cannot be applied to operands of type 'Net.Rtccloud.Sdk.Event.Meetingpoint.StatusEvent.Type' and 'System.Type' (CS0019) (SightCallBindingLibrary)
C:\Users\user\Documents\Projects\SightCallBindingLibrary\SightCallBindingLibrary\obj\Debug\generated\src\Net.Rtccloud.Sdk.Event.Meetingpoint.StatusEvent.cs(7,7): Error CS1502: The best overloaded method match for 'Android.Runtime.JNIEnv.StartCreateInstance(System.IntPtr, System.IntPtr, params Android.Runtime.JValue[])' has some invalid arguments (CS1502) (SightCallBindingLibrary)
C:\Users\user\Documents\Projects\SightCallBindingLibrary\SightCallBindingLibrary\obj\Debug\generated\src\Net.Rtccloud.Sdk.Event.Meetingpoint.StatusEvent.cs(59,59): Error CS1503: Argument 1: cannot convert from 'Net.Rtccloud.Sdk.Event.Meetingpoint.StatusEvent.Type' to 'System.IntPtr' (CS1503) (SightCallBindingLibrary)
C:\Users\user\Documents\Projects\SightCallBindingLibrary\SightCallBindingLibrary\obj\Debug\generated\src\Net.Rtccloud.Sdk.Event.Meetingpoint.StatusEvent.cs(71,71): Error CS1503: Argument 2: cannot convert from 'string' to 'System.IntPtr' (CS1503) (SightCallBindingLibrary)
C:\Users\user\Documents\Projects\SightCallBindingLibrary\SightCallBindingLibrary\obj\Debug\generated\src\Net.Rtccloud.Sdk.Event.Meetingpoint.StatusEvent.cs(8,8): Error CS0019: Operator '==' cannot be applied to operands of type 'Net.Rtccloud.Sdk.Event.Meetingpoint.StatusEvent.Type' and 'System.Type' (CS0019) (SightCallBindingLibrary)
能否告诉我如何解决上述问题?
编辑
<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']" />
-->
<!-- <remove-node path="/api/package[@name='Net.Rtccloud.Sdk.Event.Meetingpoint']/class[@name='RequestEvent.Type']" />-->
<!-- <remove-node path="/api/package[@name='Net.Rtccloud.Sdk.Event.Meetingpoint.RequestEvent']"/>-->
<!-- <remove-node path="/api/package[@name='Net.Rtccloud.Sdk.Event.Meetingpoint.MeetingPointEvent']/class[@name='RequestEvent.Type']"/>-->
</metadata>
我已经注释掉了我尝试过的各种方法,因为我收到一条警告,指出删除的节点路径不匹配任何节点。
如 here 所述,绑定应遵守 java 程序包命名约定(小写)。
这里应该是:
net.rtccloud.sdk.event.meetingpoint.RequestEvent
而不是
Net.Rtccloud.Sdk.Event.Meetingpoint.RequestEvent