# NullPointer exception on video-sdk initialize causing app crash -- React-Native Android

**URL:** <https://devforum.zoom.us/t/nullpointer-exception-on-video-sdk-initialize-causing-app-crash-react-native-android/83930>\
**Category:** React Native\
**Tags:** android\
**Created:** [March 1, 2023, 10:12am UTC](https://devforum.zoom.us/t/nullpointer-exception-on-video-sdk-initialize-causing-app-crash-react-native-android/83930 "2023-03-01T10:12:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![appdev-staywell](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@appdev-staywell](https://devforum.zoom.us/u/appdev-staywell)\
**Post date:** [March 1, 2023, 10:12am UTC](https://devforum.zoom.us/t/nullpointer-exception-on-video-sdk-initialize-causing-app-crash-react-native-android/83930/1 "2023-03-01T10:12:02Z")

</div>

**Description**  
On some devices, we get a NullPointer exception when loading the app from install.

The workaround is for the user to clear the app cache to make the app work. However, this is not possible for end-users.

**Errors**  
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:5) at org.webrtc.voiceengine.VoiceEngineCompat.selectAudioDeviceAPIType(VoiceEngineCompat.java:1) at org.webrtc.voiceengine.VoiceEngineCompat.isBluetoothScoCupported(VoiceEngineCompat.java:33) at us.zoom.internal.SDKApplication.onSDKCreated(SDKApplication.java:50) at us.zoom.internal.SDKApplication.initializeForSDK(SDKApplication.java:8) at us.zoom.sdk.d.initialize(ZoomVideoSDKImpl.java:18) at com.reactnativezoom.videosdk.RNZoomVideoSdkModule$1.run(RNZoomVideoSdkModule.java:120) at android.os.Handler.handleCallback(Handler.java:914)

**Which React Native Video SDK version?**  
@zoom1234/react-native-videosdk version 1.3.1

**Video SDK Code Snippets**  
RNZoomVideoSdkModule.java

```auto
  @ReactMethod
  public void initSdk(ReadableMap config, Promise promise) {
  ...
        params.videoRawDataMemoryMode = RNZoomVideoSdkRawDataMemoryMode.valueOf(config.getString("videoRawDataMemoryMode"));
        params.audioRawDataMemoryMode = RNZoomVideoSdkRawDataMemoryMode.valueOf(config.getString("audioRawDataMemoryMode"));
        params.shareRawDataMemoryMode = RNZoomVideoSdkRawDataMemoryMode.valueOf(config.getString("shareRawDataMemoryMode"));

        ZoomVideoSDK sdk = ZoomVideoSDK.getInstance();
        int initResult = sdk.initialize(reactContext.getCurrentActivity(), params);
  ...
  }

```

**To Reproduce(If applicable)**  
Steps to reproduce the behavior:

1. Generate release APK for android
2. Install the APK
3. Launch the app
4. App crashes

**Troubleshooting Routes**

1. Tried to catch the error and:  
a. programmatically clear any cache in the context  
b. set delay and try to re-initialize the sdk

**Smartphone (please complete the following information):**

- Device: Android
- OS: Android 10 QKQ1.190825.002

**Additional context**  
Similar cases but with no clear resolution:  
[https://devforum.zoom.us/t/video-sdk-demo-app-crashes-when-starting/47005/3](https://video-sdk-demo-app-crashes-when-starting)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [March 31, 2023, 10:12am UTC](https://devforum.zoom.us/t/nullpointer-exception-on-video-sdk-initialize-causing-app-crash-react-native-android/83930/3 "2023-03-31T10:12:36Z")

</div>

This topic was automatically closed after 30 days. New replies are no longer allowed.
