twilio / voice-quickstart-android

Quickstart app for the Voice Android SDK
https://www.twilio.com/docs/api/voice-sdk/android/getting-started
MIT License
187 stars 141 forks source link

java.lang.UnsatisfiedLinkError: No implementation found for void com.twilio.voice.Call.nativeMute(long, boolean) (tried Java_com_twilio_voice_Call_nativeMute and Java_com_twilio_voice_Call_nativeMute__JZ) #511

Closed beinghassandar1 closed 2 years ago

beinghassandar1 commented 2 years ago

Before filing an issue please check that the issue is not already addressed by the following:

Please ensure that you are not sharing any java.lang.UnsatisfiedLinkError: No implementation found for void com.twilio.voice.Call.nativeMute(long, boolean) (tried Java_com_twilio_voice_Call_nativeMute and Java_com_twilio_voice_Call_nativeMute__JZ) O Personally Identifiable Information(PII) or sensitive account information (API keys, credentials, etc.) when reporting an issue.

Description

Hello. I am using Twilio voice SDK and there is this issue that keeps happening on some devices.

[Description of the issue]

Steps to Reproduce

After Call is established, mute the mic.

Code

// Code that helps reproduce the issue

Expected Behavior

[What you expect to happen]

Actual Behavior

[What actually happens]

Reproduces How Often

Once a week

[What percentage of the time does it reproduce?]

Twilio Call SID(s)

You can find the Call SID in the SDK using Call.getSid() or CallInvite.getCallSid(). The Call SID can also be found on the Twilio Calls Console: https://www.twilio.com/console/voice/calls/logs.

Logs

// Log output when the issue occurs

com.twilio.voice.Call.nativeMute Call.java com.twilio.voice.Call.mute Call.java:1159 communication.twilio.TwilioComManager.setMicMute TwilioComManager.java:849 communication.fragments.TwilioCallingFragment.setUpMicSpeakerUi TwilioCallingFragment.java:243 communication.fragments.TwilioCallingFragment.setCallAcceptedUI TwilioCallingFragment.java:619 communication.fragments.TwilioCallingFragment.incomingCallAccepted TwilioCallingFragment.java:583 communication.twilio.TwilioComManager.acceptIncomingCall TwilioComManager.java:548 communication.fragments.TwilioCallingFragment.onClick TwilioCallingFragment.java:368 android.view.View.performClick View.java:7472 android.view.View.performClickInternal View.java:7445 android.view.View.access$3600 View.java:820 android.view.View$PerformClick.run View.java:28533 android.os.Handler.handleCallback Handler.java:938 android.os.Handler.dispatchMessage Handler.java:99 android.os.Looper.loop Looper.java:268 android.app.ActivityThread.main ActivityThread.java:8073 java.lang.reflect.Method.invoke Method.java com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run RuntimeInit.java:627 com.android.internal.os.ZygoteInit.main ZygoteInit.java:997

Versions

All relevant version information for the issue.

Voice Android SDK

'com.twilio:voice-android:6.0.1'

OS Version

Android 9 But we did get this crash on Android 11 too.

Device Model

Huawei nova 3i

kbagchiGWC commented 2 years ago

@beinghassandar1

How are you creating the Call object thats used to mute? The native library needs to be loaded before the native functions can be called. The log snippet indicates the library was not loaded when mute was called. Can you share the code snippet?

beinghassandar1 commented 2 years ago

@kbagchiGWC

We initialize the Twilio instance when app is opened. After that, to create the call,

private void connectCall(FragmentActivity context, String contactNo, String token) {
        Map<String, String> params = new HashMap<>();
        params.put("To", contactNo);
        ConnectOptions connectOptions = new ConnectOptions.Builder(token)
                .params(params)
                .build();
        accessToken = token;
        mAudioManager.setSpeakerphoneOn(true);
        activeCallConnection = Voice.connect(context, connectOptions, new TwilioCallConnectionListener(context, this));
   }

To Mute/Unmute the call

if (activeCallConnection != null) {
            activeCallConnection.mute(mute);
        }
kbagchiGWC commented 2 years ago

Voice.connect() is one of the methods in the SDK that checks if the native library is loaded or not. If not loaded, it initiates the loading of the twilio_voice_android_s library. If your code is calling methods on the Call object returned from the Voice.connect() immediately, the library may not have completed loading yet. Once the library loads, this kind of linking error should not happen. My guess is that the library was not loaded when the following code block is executed.

if (activeCallConnection != null) {
            activeCallConnection.mute(mute);
        }

Do you know the Call.State of activeCallConnection when activeCallConnection.mute(mute) is called? To confirm the library is loaded prior to calling mute(...) you can check if the activeCallConnection is in Call.State.RINGING or Call.State.CONNECTED state.

beinghassandar1 commented 2 years ago

Interesting. I was checking this state for when we send digits like this

if (activeCallConnection != null && activeCallConnection.getState() == Call.State.CONNECTED) {
                activeCallConnection.sendDigits(digit);
        }

I'll add this for Mute function too.

kbagchiGWC commented 2 years ago

Closing this due to inactivity.