Running the basic video chat example for Android SDK keeps crashing Running the basic video chat example for Android SDK keeps crashing

Running the basic video chat example for Android SDK keeps crashing

Paul Bird

Symptom

When attempting to run the Android SDK basic video chat example on GitHub, it fails and the following stack trace is generated:

com.tokbox.sample.basicvideochat E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.tokbox.sample.basicvideochat, PID: 16499
    java.lang.NullPointerException: Attempt to read from field 'java.lang.String com.tokbox.sample.basicvideochat.network.GetSessionResponse.apiKey' on a null object reference
        at com.tokbox.sample.basicvideochat.MainActivity$4.onResponse(MainActivity.java:222)
        at retrofit2.DefaultCallAdapterFactory$ExecutorCallbackCall$1.lambda$onResponse$0$retrofit2-DefaultCallAdapterFactory$ExecutorCallbackCall$1(DefaultCallAdapterFactory.java:89)
        at retrofit2.DefaultCallAdapterFactory$ExecutorCallbackCall$1$$ExternalSyntheticLambda1.run(Unknown Source:6)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

Applies To

  • Android SDK

Resolution

  1. Locate the ServerConfig.java file
  2. Remove the default URL in the chat_server_url parameter:

    Before:

    public static final String CHAT_SERVER_URL = "https://YOURAPPNAME.herokuapp.com";

    After:

    public static final String CHAT_SERVER_URL = "";

Cause

The chat_server_url parameter references the server set up to generate sessionIds. Unless you have a server URL that exactly matches the default value to generate sessionIds, you'll either want to change it to your own or leave it blank.

Additional Information

The following URL is where you can download the basic video chat example on GitHub: https://github.com/opentok/opentok-android-sdk-samples/tree/main/Basic-Audio-Driver-Java