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
- Locate the ServerConfig.java file
-
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
Articles in this section
- How to avoid Gradle build failure with OpenTok Android SDK 2.22.0+
- Why READ_PHONE_STATE permission is required while using Video API Android SDK?
- Where can I get the Vonage Video API Android SDK?
- Inline Installation of Screen Sharing Extensions in Chrome Deprecated
- What devices does the Vonage Video Android SDK support?
- Where can I see the sample code for Vonage Video Android SDK?
- How many participants can join an Android session?
- Running the basic video chat example for Android SDK keeps crashing
- Retaining microphone access in the background using Video API Android SDK
- Screensharing outside Native SDK Application