在Xamarin Android Bindings Library中使用Twilio可编程语音的问题

时间:2018-04-04 17:10:57

标签: xamarin xamarin.android twilio xamarin-binding twilio-programmable-voice

我创建了一个绑定库项目,以便能够运行Twilio的Android可编程语音SDK(v 2.0.5 - link to download .aar file)。

我在 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(link to download .aar file)),我必须创建另一个绑定库项目(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

1 个答案:

答案 0 :(得分:0)

我添加了对RelinkerBindings项目的引用,该项目包含Twilio项目的依赖项,但不知何故显示找不到RelinkerBindings的日志,所以我删除了对项目的引用并添加了对Relinker dll文件的引用现在可以正常工作了。 不知道为什么它在参考项目时没有工作。