Laerdal / Xamarin.AzureCommunicationCalling

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

Android group call throwing exception #19

Closed NeerajRai111 closed 3 years ago

NeerajRai111 commented 3 years ago

Hi Thomas,

I am able to use your demo and able to do a video call but when I am using the same code with all the packages in another project solution then after generating token when I click on Call Group button, it is asking for permission, and after granting permission for everything, it throws this exception at this line:

_localVideoStream = new LocalVideoStream(camera, MainActivity.Instance);

Exception details:

{Java.Lang.NullPointerException: Attempt to invoke virtual method 'void android.app.Activity.requestPermissions(java.lang.String[], int)' on a null object reference at Java.Interop.JniEnvironment+StaticMethods.CallStaticVoidMethod (Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue args) [0x0006e] in <94b04e1756104d1fa1d144932ae2720c>:0 at Java.Interop.JniPeerMembers+JniStaticMethods.InvokeVoidMethod (System.String encodedMember, Java.Interop.JniArgumentValue parameters) [0x00018] in <94b04e1756104d1fa1d144932ae2720c>:0 at AndroidX.Core.App.ActivityCompat.RequestPermissions (Android.App.Activity activity, System.String[] permissions, System.Int32 requestCode) [0x00057] in D:\a\1\s\generated\androidx.core.core\obj\Release\monoandroid9.0\generated\src\AndroidX.Core.App.ActivityCompat.cs:529 at EiMMessenger.Droid.ACS.CallingManager.JoinGroup (System.Guid groupID) [0x00002] in C:\Data\ChatApp\SmallBusinessApp(Chat App)\EMiChatAPP\EiMMessenger\EiMMessenger.Android\ACS\CallingManager.cs:46 --- End of managed Java.Lang.NullPointerException stack trace --- java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.Activity.requestPermissions(java.lang.String[], int)' on a null object reference at androidx.core.app.ActivityCompat.requestPermissions(ActivityCompat.java:502) at crc64ee486da937c010f4.ButtonRenderer.n_onClick(Native Method) at crc64ee486da937c010f4.ButtonRenderer.onClick(ButtonRenderer.java:104) at android.view.View.performClick(View.java:7125) at android.view.View.performClickInternal(View.java:7102) at android.view.View.access$3500(View.java:801) at android.view.View$PerformClick.run(View.java:27336) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7356) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930) }

All the project setting and versions are exactly same as the demo project but it's still not working.

Do you have any idea, how to fix it?

tompi commented 3 years ago

Hi @NeerajRai111

Could you check your manifest file against the demo and see if you are missing something ?

NeerajRai111 commented 3 years ago

Hi @tompi, I have copied everything from demo to the new project manifest. The only difference is the name of the package. image

tompi commented 3 years ago

Sorry, I didnt read the stacktrace properly last time. The problem is most likely that you are not setting the MainActivity.Instance on start. Check usages of that in my app and copy it in yours, it should be set when you start calling.

NeerajRai111 commented 3 years ago

Thanks @tompi,

I missed to write "Instance = this;" in OnCreate() function. It is working now!