Video SDK demo app crashes when starting

I downloaded the Video SDK: zoom-instant-sdk-android-1.0.2

When the app runs, it crashes. I’m running this on a Pixel 2 XL that is using Android 11.

UPDATE:
I was able to get the app to run. If you run the app from within Android Studio, it will crash. However, if you first go to the app’s settings in Android, delete the cache and then manually set the permissions for everything the app is requesting and then launch the app manually from the launcher icon, it will run. This tells me that the demo app is relying on some permissions being enabled before launching. Personally, I would modify the demo app to check for the file storage permissions when the Welcome screen is launched and requesting permission if it isn’t enabled. The developer of the demo app probably only tested the app on a version of Android prior to 11. It should be tested on Android 11+.

The following is the log data:

2021-03-31 15:09:35.613 11846-11846/us.zoom.InstantSDKPlaygroud E/AndroidRuntime: FATAL EXCEPTION: main
    Process: us.zoom.InstantSDKPlaygroud, PID: 11846
    java.lang.RuntimeException: Unable to start activity ComponentInfo{us.zoom.InstantSDKPlaygroud/us.zoom.sdksample.WelcomeActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.String android.content.SharedPreferences.getString(java.lang.String, java.lang.String)' on a null object reference
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3449)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        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)
     Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.String android.content.SharedPreferences.getString(java.lang.String, java.lang.String)' on a null object reference
        at com.zipow.videobox.util.PreferenceUtil.readStringValue(PreferenceUtil.java:312)
        at org.webrtc.voiceengine.VoiceEngineCompat.selectAudioDeviceAPIType(VoiceEngineCompat.java:229)
        at org.webrtc.voiceengine.VoiceEngineCompat.isBluetoothScoSupported(VoiceEngineCompat.java:154)
        at us.zoom.internal.SDKApplication.onSDKCreated(SDKApplication.java:123)
        at us.zoom.internal.SDKApplication.initializeForSDK(SDKApplication.java:67)
        at us.zoom.sdk.c.initialize(ZoomInstantSDKImpl.java:464)
        at us.zoom.sdksample.WelcomeActivity.initSDK(WelcomeActivity.java:186)
        at us.zoom.sdksample.WelcomeActivity.onCreate(WelcomeActivity.java:50)
        at android.app.Activity.performCreate(Activity.java:8000)
        at android.app.Activity.performCreate(Activity.java:7984)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601) 
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        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) 
2021-03-31 15:09:35.613 11846-11846/us.zoom.InstantSDKPlaygroud E/CrashHandler: java.lang.RuntimeException: Unable to start activity ComponentInfo{us.zoom.InstantSDKPlaygroud/us.zoom.sdksample.WelcomeActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.String android.content.SharedPreferences.getString(java.lang.String, java.lang.String)' on a null object reference
2021-03-31 15:09:35.613 11846-11846/us.zoom.InstantSDKPlaygroud E/CrashHandler: java.lang.RuntimeException: Unable to start activity ComponentInfo{us.zoom.InstantSDKPlaygroud/us.zoom.sdksample.WelcomeActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.String android.content.SharedPreferences.getString(java.lang.String, java.lang.String)' on a null object reference

Hi @AndroidDev,

Sorry to hear you were running into this crash, and thanks for updating it now that it was resolved! We have not yet been able to reproduce this, but will continue to keep an eye out for similar issues.

Thanks!

This problem came back and the solution I mentioned in my original post no longer worked. I spent hours trying to figure out what the problem could be. The app works fine on a Nexus 6P running Android 8.1. But running it on a Pixel 2 XL (Android 11) would crash on startup. I tried the following:

  • Uninstalled the app multiple times
  • Cleaned my build
  • Restarted device multiple times
  • Made sure the app had all the required permissions

In the end, I began to suspect that the version my app was running was not the actual version being installed. This led me to go to my Google Drive account where Android stores backups and deleted the device’s backup. I then uninstalled the app and restarted the device. After manually setting the permissions, the app no longer crashed.

The app crashes when:

ZoomInstantSDK.getInstance().initialize(context, params)

is called. The initialize function internally reads stuff from Shared Preferences. The crash occurs most likely because the value of some Shared Preference is being set to null and this null value is being used somewhere else. Your developers should add code to test if the value is null when read from Shared Preferences and set it to some default value if it is.

By default, Android will backup these Shared Preference values to a user’s Google Drive account when the device’s backup is done and restore those values if the app gets reinstalled. This means, that for whatever reason, if the value got set to null on the device, it will be restored to null and result in crashes.

Not setting the Shared Preferences values to a default value when they are read as null should be consider a major bug as it will prevent the user from running future updates of an app when those values get set to null.

In my original post, the log output indicates where you should be focusing on the problem:

com.zipow.videobox.util.PreferenceUtil.readStringValue(PreferenceUtil.java:312)

Others have posted a similar problem related to PreferenceUtil reading stuff, so this is clearly an issue that needs to be fixed.

Hi @AndroidDev,

Thank you for the additional details. I agree that this if the SDK is doing something incorrectly when reading from shared prefs, it should be resolved. While we begin looking into a solution for this, can you please provide the full initialization code being used?

Thanks!

This is the code for initializing the SDK:

val params = ZoomInstantSDKInitParams()
params.domain = "https://zoom.us"
params.enableLog = true
params.videoRawDataMemoryMode = ZoomInstantSDKRawDataMemoryMode.ZoomInstantSDKRawDataMemoryModeHeap
params.audioRawDataMemoryMode = ZoomInstantSDKRawDataMemoryMode.ZoomInstantSDKRawDataMemoryModeHeap
params.shareRawDataMemoryMode = ZoomInstantSDKRawDataMemoryMode.ZoomInstantSDKRawDataMemoryModeHeap

val ret = ZoomInstantSDK.getInstance().initialize(App.context, params)

The App.context is a reference to the activity context and is present.