1

我创建了一个绑定库项目,以便能够运行 Twilio 的 Android 可编程语音 SDK(v 2.0.5 -下载 .aar 文件的链接)。

我在Metadata.xml中添加了这行代码来修复一些错误:

<!-- solving: Error CS0102  The type 'ErrorEventArgs' already contains a definition for 'P0'  TwilioBindings C:\...\TwilioBindings\obj\Debug\generated\src\Com.Twilio.Voice.IRegistrationListener.cs    -->
<attr path="/api/package[@name='com.twilio.voice']/interface[@name='RegistrationListener']/method[@name='onError']" name="managedName">RegistrationListenerOnError</attr>  
<attr path="/api/package[@name='com.twilio.voice']/interface[@name='UnregistrationListener']/method[@name='onError']" name="managedName">UnregistrationListenerOnError</attr>

<!-- Error  CS0234  The type or namespace name 'InternalCall' does not exist in the namespace 'Com.Twilio.Voice' (are you missing an assembly reference?)   TwilioBindings  C:\...\TwilioBindings\obj\Debug\generated\src\Com.Twilio.Voice.Call.cs -->
<attr path="/api/package[@name='com.twilio.voice']/class[@name='InternalCall']" name="visibility">public</attr>

<!-- Error  CS0115  'Call.OnWarning(IDictionary)': no suitable method found to override TwilioBindings  C:\...\TwilioBindings\obj\Debug\generated\src\Com.Twilio.Voice.Call.cs -->
<attr path="/api/package[@name='com.twilio.voice']/class[@name='Call']/method[@name='onWarning' and count(parameter)=1 and parameter[1][@type='java.util.HashMap']]/parameter[1]" name="type">java.util.HashMap&lt;java.lang.String, java.lang.Object&gt;</attr>

它编译成功,但是当我调用 Voice.Call() 时,该方法不返回任何内容,如果我在 ui 线程中调用它,ui 将永远卡住。我暂停了调试器,这样我就可以看到代码的哪一部分正在运行,它正在等待 Com.Twilio.Voice.Voice 中后续行的返回:

global::Com.Twilio.Voice.Call __ret = global::Java.Lang.Object.GetObject<global::Com.Twilio.Voice.Call> (JNIEnv.CallStaticObjectMethod  (class_ref, id_call_Landroid_content_Context_Ljava_lang_String_Ljava_util_Map_Lcom_twilio_voice_Call_Listener_, __args), JniHandleOwnership.TransferLocalRef);

我的提示是,我在Metadata.xml中添加的某些行可能不正确,或者我需要添加更多。

我有一些警告可能有助于解决问题:

Warning     Type com.getkeepsafe.relinker.ReLinker: FxDG naming violation: Type name 'ReLinker' matches namespace part 'Relinker'.  RelinkerBindings    C:\...\RelinkerBindings\BINDINGSGENERATOR   

Warning     Skipping Com.Getkeepsafe.Relinker.ReLinkerInstance.Force, due to a duplicate field, method or nested type name. RelinkerBindings    C:\...\RelinkerBindings\BINDINGSGENERATOR   

Warning     Type com.getkeepsafe.relinker.ReLinker: FxDG naming violation: Type name 'ReLinker' matches namespace part 'Relinker'.  RelinkerBindings    C:\...\RelinkerBindings\BINDINGSGENERATOR   

Warning     ignoring option UseSplitVerifier; support was removed in 8.0    RelinkerBindings    C:\...\RelinkerBindings\JARTOXML        

Warning CS0108  'Call.IInternalListener.OnConnectFailure(Call, CallException)' hides inherited member 'Call.IListener.OnConnectFailure(Call, CallException)'. Use the new keyword if hiding was intended.   TwilioBindings  C:\...\TwilioBindings\obj\Debug\generated\src\Com.Twilio.Voice.Call.cs  17  Active

Warning CS0108  'Call.IInternalListener.OnConnected(Call)' hides inherited member 'Call.IListener.OnConnected(Call)'. Use the new keyword if hiding was intended.   TwilioBindings  C:\...\TwilioBindings\obj\Debug\generated\src\Com.Twilio.Voice.Call.cs  21  Active

Warning CS0108  'Call.IInternalListener.OnDisconnected(Call, CallException)' hides inherited member 'Call.IListener.OnDisconnected(Call, CallException)'. Use the new keyword if hiding was intended.   TwilioBindings  C:\...\TwilioBindings\obj\Debug\generated\src\Com.Twilio.Voice.Call.cs  29  Active

Warning CS0108  'Event.GetType()' hides inherited member 'object.GetType()'. Use the new keyword if hiding was intended.    TwilioBindings  C:\...\TwilioBindings\obj\Debug\generated\src\Com.Twilio.Voice.Impl.Session.Event.cs    222 Active

Warning IDE0006 Error encountered while loading the project. Some project features, such as full solution analysis for the failed project and projects that depend on it, have been disabled.   TwilioBindings      1   Active

Warning     For type Com.Twilio.Voice.InternalCall, base interface com.twilio.voice.RTCMonitorCommand.Listener is invalid.  TwilioBindings  C:\...\TwilioBindings\BINDINGSGENERATOR     

Warning     For type Com.Twilio.Voice.InternalCall, base interface com.twilio.voice.EventPublisher.EventPublisherListener is invalid.   TwilioBindings  C:\...\TwilioBindings\BINDINGSGENERATOR     

Warning     Type com.twilio.voice.Voice: FxDG naming violation: Type name 'Voice' matches namespace part 'Voice'.   TwilioBindings  C:\...\TwilioBindings\BINDINGSGENERATOR     

Warning     Type com.twilio.voice.Voice: FxDG naming violation: Type name 'Voice' matches namespace part 'Voice'.   TwilioBindings  C:\...\TwilioBindings\BINDINGSGENERATOR     

Warning     Invalid parameter type com.twilio.voice.EventPayload.WarningName in method OnWarningCleared in managed type Com.Twilio.Voice.InternalCall.  TwilioBindings  C:\...\TwilioBindings\BINDINGSGENERATOR     

Warning     Invalid parameter type com.twilio.voice.EventPayload.WarningName in method OnWarningCleared in managed type Com.Twilio.Voice.Call.  TwilioBindings  C:\...\TwilioBindings\BINDINGSGENERATOR     

Warning     ignoring option UseSplitVerifier; support was removed in 8.0    TwilioBindings  C:\...\TwilioBindings\JARTOXML

注意:因为 Twilio 的 Android 可编程语音 SDK 有一个依赖项(ReLinker 1.2.2(下载 .aar 文件的链接)),我不得不创建另一个绑定库项目(RelinkerBindings)来包含该依赖项,然后我在 Twilio 的绑定项目中引用了它。

我以前从未在 xamarin 中做过任何绑定项目,所以我对此有点陌生。

有谁知道如何解决这个问题?

提前致谢。

编辑:

我已经看到了 logcat 日志,这就是我调用 Voice.Call() 时发生的情况:

04-27 10:17:00.118  7208  7247 E CallCommandHandlerImpl: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/getkeepsafe/relinker/ReLinker;
04-27 10:17:00.118  7208  7247 E CallCommandHandlerImpl:        at com.twilio.voice.UserAgent.loadLibrary(UserAgent.java:261)
04-27 10:17:00.118  7208  7247 E CallCommandHandlerImpl:        at com.twilio.voice.UserAgent.<init>(UserAgent.java:57)
04-27 10:17:00.118  7208  7247 E CallCommandHandlerImpl:        at com.twilio.voice.UserAgent.get(UserAgent.java:107)
04-27 10:17:00.118  7208  7247 E CallCommandHandlerImpl:        at com.twilio.voice.CallCommandHandlerImpl.run(CallCommandHandlerImpl.java:50)
04-27 10:17:00.118  7208  7247 E CallCommandHandlerImpl: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.getkeepsafe.relinker.ReLinker" on path: DexPathList[[zip file "/data/app/com.globalactone.ecare-1/base.apk"],nativeLibraryDirectories=[/data/app/com.globalactone.ecare-1/lib/x86, /system/fake-libs, /data/app/com.globalactone.ecare-1/base.apk!/lib/x86, /system/lib, /vendor/lib]]
04-27 10:17:00.118  7208  7247 E CallCommandHandlerImpl:        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
04-27 10:17:00.118  7208  7247 E CallCommandHandlerImpl:        at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
04-27 10:17:00.118  7208  7247 E CallCommandHandlerImpl:        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
04-27 10:17:00.118  7208  7247 E CallCommandHandlerImpl:        ... 4 more
4

1 回答 1

0

我添加了对 RelinkerBindings 项目的引用,该项目包含 Twilio 项目的依赖项,但不知何故,日志显示未找到 RelinkerBindings,因此我删除了对项目的引用并添加了对 Relinker dll 文件的引用及其现在工作。不知道为什么它在引用该项目时不起作用。

于 2018-05-04T10:42:28.737 回答