简体   繁体   中英

java.lang.IllegalStateException: SinchClient not started

I am following the tutorial ( https://www.sinch.com/tutorials/android-app-to-app-voip-tutorial/ ) to develop an Android app-to-app voice calling feature.

Please let me know suggestions to fix this.

Thanks Siddharth


Scenario Details

  1. For calling side I created an app via this tutorial : github.com/sinch/app-app-calling-android.

  2. For receiving side, I used the sample app sinch-android-rtc-3.12.5/samples/sinch-rtc-sample-calling

  3. I ensured that the Key/Secret & Environment were matching for both sides

  4. Both calling & receiving apps build and startup normally

I am consistently getting this exception on Calling Side:


E/AndroidRuntime: FATAL EXCEPTION: main Process: com.sinch.workshopskeleton, PID: 24797 java.lang.IllegalStateException: SinchClient not started at com.sinch.android.rtc.internal.client.calling.DefaultCallClient.throwUnlessStarted(Unknown Source) at com.sinch.android.rtc.internal.client.calling.DefaultCallClient.call(Unknown Source) at com.sinch.android.rtc.internal.client.calling.DefaultCallClient.callUser(Unknown Source) at com.sinch.android.rtc.internal.client.calling.DefaultCallClient.callUser(Unknown Source) at com.sinch.apptoappcall.CallActivity$1.onClick(CallActivity.java:67) at android.view.View.performClick(View.java:5612) at android.view.View$PerformClick.run(View.java:22285) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6123) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$Met hodAndArgsCaller.run(ZygoteInit.java:867) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)


At the following UNDERLINED piece of code in the class com.sinch.apptoappcall.CallActivity =>


button.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        if (call == null) {
call = sinchClient.getCallClient().callUser(recipientId);  
call.addCallListener(new SinchCallListener());
button.setText("Hang Up");
} else {
call.hangup();
}
}
});

You should add this before you call sinchClient.start() to check if the sinch successfully started or failed

    sinchClient.addSinchClientListener(this)
    override fun onClientStarted(p0: SinchClient?) {
        Timber.d("Sinch Client Started")
    }

    override fun onClientStopped(p0: SinchClient?) {
        Timber.d("Sinch Client Stopped")
    }

    override fun onClientFailed(p0: SinchClient?, p1: SinchError?) {
        Timber.d("Sinch Client Failed")
        /// You should add logic to re-start sinch client here
    }

    override fun onRegistrationCredentialsRequired(
        p0: SinchClient?,
        p1: ClientRegistration?
    ) {
        Timber.d("Sinch Client Credential Required")
    }

    override fun onLogMessage(p0: Int, p1: String?, p2: String?) {
        Timber.d(p1, p2)
    }

You could read the referencehere

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM