Laerdal / Xamarin.AzureCommunicationCalling

Xamarin iOS and Android binding libraries for Microsofts Azure Communication Services
MIT License
35 stars 11 forks source link

problem with the solution in android #1

Closed smartinez5050 closed 4 years ago

smartinez5050 commented 4 years ago

Hi!

While evaluating ACS we cross with this project. It looks very promissing, thanks for shearing. We are evaluating it and eventually we may contribute too.

We manage to make the iOS solution to work, however we are facing some issues with Android.

The issue happens at runtime, after we got the token from the API and we try to execute the following code:

// Metadata.xml XPath method reference: path="/api/package[@name='com.azure.communication.calling']/class[@name='CallClient']/method[@name='createCallAgent' and count(parameter)=2 and parameter[1][@type='android.content.Context'] and parameter[2][@type='com.azure.android.communication.common.CommunicationUserCredential']]"
[Register ("createCallAgent", "(Landroid/content/Context;Lcom/azure/android/communication/common/CommunicationUserCredential;)Ljava/util/concurrent/Future;", "GetCreateCallAgent_Landroid_content_Context_Lcom_azure_android_communication_common_CommunicationUserCredential_Handler")]
public virtual unsafe global::Java.Util.Concurrent.IFuture CreateCallAgent (global::Android.Content.Context appContext, global::Com.Azure.Android.Communication.Common.CommunicationUserCredential communicationUserCredential)
{
  const string __id = "createCallAgent.(Landroid/content/Context;Lcom/azure/android/communication/common/CommunicationUserCredential;)Ljava/util/concurrent/Future;";
  try {
    JniArgumentValue* __args = stackalloc JniArgumentValue [2];
    __args [0] = new JniArgumentValue ((appContext == null) ? IntPtr.Zero : ((global::Java.Lang.Object) appContext).Handle);
    __args [1] = new JniArgumentValue ((communicationUserCredential == null) ? IntPtr.Zero : ((global::Java.Lang.Object) communicationUserCredential).Handle);
    var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, __args);
    return global::Java.Lang.Object.GetObject<global::Java.Util.Concurrent.IFuture> (__rm.Handle, JniHandleOwnership.TransferLocalRef);
  } finally {
  }
}

it crashes and report the following error:

[cationvideotes] Rejecting re-init on previously-failed class java.lang.Class<com.microsoft.media.NTLMEngineImpl>: java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/impl/auth/NTLMEngine;
[cationvideotes]   at java.lang.Class java.lang.VMClassLoader.findLoadedClass(java.lang.ClassLoader, java.lang.String) (VMClassLoader.java:-2)
[cationvideotes]   at java.lang.Class java.lang.ClassLoader.findLoadedClass(java.lang.String) (ClassLoader.java:738)
[cationvideotes]   at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:363)
[cationvideotes]   at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
[cationvideotes] Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.impl.auth.NTLMEngine" on path: DexPathList[[zip file "/data/app/com.laerdal.azurecommunicationvideotest-8SRXANYuuUeGVrYTI0DkQQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.laerdal.azurecommunicationvideotest-8SRXANYuuUeGVrYTI0DkQQ==/lib/x86_64, /data/app/com.laerdal.azurecommunicationvideotest-8SRXANYuuUeGVrYTI0DkQQ==/base.apk!/lib/x86_64, /system/lib64]]
[cationvideotes]   at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:134)
[cationvideotes]   at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
[cationvideotes]   at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
[cationvideotes]   at java.lang.Class java.lang.VMClassLoader.findLoadedClass(java.lang.ClassLoader, java.lang.String) (VMClassLoader.java:-2)
[cationvideotes]   at java.lang.Class java.lang.ClassLoader.findLoadedClass(java.lang.String) (ClassLoader.java:738)
[cationvideotes]   at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:363)
[cationvideotes]   at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
[cationvideotes] 
[LYNC PAL] findClass com/microsoft/media/RtcPalEnvironment loader 0x3896
[pool-1-thread-1] type=1400 audit(0.0:729): avc: denied { search } for name="net" dev="sysfs" ino=2738 scontext=u:r:untrusted_app:s0:c87,c256,c512,c768 tcontext=u:object_r:sysfs_net:s0 tclass=dir permissive=0
[pool-1-thread-1] type=1400 audit(0.0:730): avc: denied { search } for name="net" dev="sysfs" ino=2738 scontext=u:r:untrusted_app:s0:c87,c256,c512,c768 tcontext=u:object_r:sysfs_net:s0 tclass=dir permissive=0
[pool-1-thread-1] type=1400 audit(0.0:731): avc: denied { search } for name="net" dev="sysfs" ino=2738 scontext=u:r:untrusted_app:s0:c87,c256,c512,c768 tcontext=u:object_r:sysfs_net:s0 tclass=dir permissive=0
[cationvideotes] java_vm_ext.cc:542] JNI DETECTED ERROR IN APPLICATION: JNI NewStringUTF called with pending exception java.lang.ClassNotFoundException: Didn't find class "com/microsoft/media/NTLMEngineImpl" on path: DexPathList[[zip file "/data/app/com.laerdal.azurecommunicationvideotest-8SRXANYuuUeGVrYTI0DkQQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.laerdal.azurecommunicationvideotest-8SRXANYuuUeGVrYTI0DkQQ==/lib/x86_64, /data/app/com.laerdal.azurecommunicationvideotest-8SRXANYuuUeGVrYTI0DkQQ==/base.apk!/lib/x86_64, /system/lib64]]
[cationvideotes] java_vm_ext.cc:542]   at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:134)
[cationvideotes] java_vm_ext.cc:542]   at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
[cationvideotes] java_vm_ext.cc:542]   at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
[cationvideotes] java_vm_ext.cc:542] 
[cationvideotes] java_vm_ext.cc:542]     in call to NewStringUTF
[cationvideotes] java_vm_ext.cc:542] "Thread-24" daemon prio=5 tid=27 Runnable
[cationvideotes] java_vm_ext.cc:542]   | group="main" sCount=0 dsCount=0 flags=0 obj=0x12fc0000 self=0x730d3f79d000
[cationvideotes] java_vm_ext.cc:542]   | sysTid=12854 nice=0 cgrp=default sched=0/0 handle=0x730d3a4034f0
[cationvideotes] java_vm_ext.cc:542]   | state=R schedstat=( 22254689 39486295 35 ) utm=1 stm=1 core=3 HZ=100
[cationvideotes] java_vm_ext.cc:542]   | stack=0x730d3a308000-0x730d3a30a000 stackSize=1009KB
[cationvideotes] java_vm_ext.cc:542]   | held mutexes= "mutator lock"(shared held)
[cationvideotes] java_vm_ext.cc:542]   native: #00 pc 0000000000403e33  /system/lib64/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, int, BacktraceMap*, char const*, art::ArtMethod*, void*, bool)+227)
[cationvideotes] java_vm_ext.cc:542]   native: #01 pc 00000000004ee1f7  /system/lib64/libart.so (art::Thread::DumpStack(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, bool, BacktraceMap*, bool) const+343)
[cationvideotes] java_vm_ext.cc:542]   native: #02 pc 000000000031da53  /system/lib64/libart.so (art::JavaVMExt::JniAbort(char const*, char const*)+1011)
[cationvideotes] java_vm_ext.cc:542]   native: #03 pc 000000000031de52  /system/lib64/libart.so (art::JavaVMExt::JniAbortV(char const*, char const*, __va_list_tag*)+82)
[cationvideotes] java_vm_ext.cc:542]   native: #04 pc 00000000000fce67  /system/lib64/libart.so (art::(anonymous namespace)::ScopedCheck::AbortF(char const*, ...)+183)
[cationvideotes] java_vm_ext.cc:542]   native: #05 pc 00000000000fb72e  /system/lib64/libart.so (art::(anonymous namespace)::ScopedCheck::CheckPossibleHeapValue(art::ScopedObjectAccess&, char, art::(anonymous namespace)::JniValueType)+1182)
[cationvideotes] java_vm_ext.cc:542]   native: #06 pc 00000000000fa9b6  /system/lib64/libart.so (art::(anonymous namespace)::ScopedCheck::Check(art::ScopedObjectAccess&, bool, char const*, art::(anonymous namespace)::JniValueType*)+758)
[cationvideotes] java_vm_ext.cc:542]   native: #07 pc 00000000000f0bf8  /system/lib64/libart.so (art::(anonymous namespace)::CheckJNI::NewStringUTF(_JNIEnv*, char const*)+824)
[cationvideotes] java_vm_ext.cc:542]   native: #08 pc 0000000000afe3a4  /data/app/com.laerdal.azurecommunicationvideotest-8SRXANYuuUeGVrYTI0DkQQ==/lib/x86_64/libRtmMediaManagerDyn.so (JNI_Pal_Init+258)
[cationvideotes] java_vm_ext.cc:542]   native: #09 pc 000000000049e48a  /data/app/com.laerdal.azurecommunicationvideotest-8SRXANYuuUeGVrYTI0DkQQ==/lib/x86_64/libACSCallingShared.so (???)
[cationvideotes] java_vm_ext.cc:542]   native: #10 pc 000000000049c3f3  /data/app/com.laerdal.azurecommunicationvideotest-8SRXANYuuUeGVrYTI0DkQQ==/lib/x86_64/libACSCallingShared.so (???)
[cationvideotes] java_vm_ext.cc:542]   native: #11 pc 0000000000464938  /data/app/com.laerdal.azurecommunicationvideotest-8SRXANYuuUeGVrYTI0DkQQ==/lib/x86_64/libACSCallingShared.so (???)
[cationvideotes] java_vm_ext.cc:542]   native: #12 pc 0000000000464527  /data/app/com.laerdal.azurecommunicationvideotest-8SRXANYuuUeGVrYTI0DkQQ==/lib/x86_64/libACSCallingShared.so (???)
[cationvideotes] java_vm_ext.cc:542]   native: #13 pc 000000000043e9fc  /data/app/com.laerdal.azurecommunicationvideotest-8SRXANYuuUeGVrYTI0DkQQ==/lib/x86_64/libACSCallingShared.so (???)
[cationvideotes] java_vm_ext.cc:542]   native: #14 pc 0000000000931ea7  /data/app/com.laerdal.azurecommunicationvideotest-8SRXANYuuUeGVrYTI0DkQQ==/lib/x86_64/libACSCallingShared.so (???)
[cationvideotes] java_vm_ext.cc:542]   native: #15 pc 00000000009322f2  /data/app/com.laerdal.azurecommunicationvideotest-8SRXANYuuUeGVrYTI0DkQQ==/lib/x86_64/libACSCallingShared.so (???)
[cationvideotes] java_vm_ext.cc:542]   native: #16 pc 000000000092bb3b  /data/app/com.laerdal.azurecommunicationvideotest-8SRXANYuuUeGVrYTI0DkQQ==/lib/x86_64/libACSCallingShared.so (???)
[cationvideotes] java_vm_ext.cc:542]   native: #17 pc 000000000092ba8a  /data/app/com.laerdal.azurecommunicationvideotest-8SRXANYuuUeGVrYTI0DkQQ==/lib/x86_64/libACSCallingShared.so (???)
[cationvideotes] java_vm_ext.cc:542]   native: #18 pc 000000000092bd6a  /data/app/com.laerdal.azurecommunicationvideotest-8SRXANYuuUeGVrYTI0DkQQ==/lib/x86_64/libACSCallingShared.so (???)
[cationvideotes] java_vm_ext.cc:542]   native: #19 pc 0000000000931ea7  /data/app/com.laerdal.azurecommunicationvideotest-8SRXANYuuUeGVrYTI0DkQQ==/lib/x86_64/libACSCallingShared.so (???)
[cationvideotes] java_vm_ext.cc:542]   native: #20 pc 000000000092a82a  /data/app/com.laerdal.azurecommunicationvideotest-8SRXANYuuUeGVrYTI0DkQQ==/lib/x86_64/libACSCallingShared.so (???)
[cationvideotes] java_vm_ext.cc:542]   native: #21 pc 000000000092a60c  /data/app/com.laerdal.azurecommunicationvideotest-8SRXANYuuUeGVrYTI0DkQQ==/lib/x86_64/libACSCallingShared.so (???)
[cationvideotes] java_vm_ext.cc:542]   native: #22 pc 000000000094a6d8  /data/app/com.laerdal.azurecommunicationvideotest-8SRXANYuuUeGVrYTI0DkQQ==/lib/x86_64/libACSCallingShared.so (???)
[cationvideotes] java_vm_ext.cc:542]   native: #23 pc 0000000000092bab  /system/lib64/libc.so (__pthread_start(void*)+27)
[cationvideotes] java_vm_ext.cc:542]   native: #24 pc 000000000002af2d  /system/lib64/libc.so (__start_thread+61)
[cationvideotes] java_vm_ext.cc:542]   (no managed stack frames)
[cationvideotes] java_vm_ext.cc:542] 
tompi commented 4 years ago

Which device/android version are you using? I just realized i only tested on a pretty old device(galaxy s7). Could you try this: https://www.google.com/amp/s/blog.jakelee.co.uk/how-to-fix-noclassdeffounderror-failed-resolution-of-lorg-apache-http-protocolversion/amp/

Ill test on a newer droid version at work tomorrow to confirm

kagbakpem commented 4 years ago

@smartinez5050, please add this dependency under the <application></application> tag in the app manifest. <uses-library android:name="org.apache.http.legacy" android:required="false"/>

See this for more context: https://developer.android.com/about/versions/pie/android-9.0-changes-28#apache-p Thanks

CARP-Kaiser commented 3 years ago

@kagbakpem thank you! That is a good find.