[BUG] java.lang.NullPointerException: context param can not be null.
Describe the bug App crashes when, I guess, it tries to play an alert sound upon receiving a PubNub message. This is the stack trace I get from AppCenter report:
com.johnsonsu.rnsoundplayer.RNSoundPlayerModule.mountSoundFile
RNSoundPlayerModule.java, line 10 java.lang.NullPointerException: context param can not be null.
android.media.MediaPlayer.setDataSource MediaPlayer.java:1105
android.media.MediaPlayer.setDataSource MediaPlayer.java:1072
com.johnsonsu.rnsoundplayer.RNSoundPlayerModule.mountSoundFile RNSoundPlayerModule.java:10
com.johnsonsu.rnsoundplayer.RNSoundPlayerModule.playSoundFile RNSoundPlayerModule.java:1
java.lang.reflect.Method.invoke Method.java
com.facebook.react.bridge.JavaMethodWrapper.invoke JavaMethodWrapper.java:18
com.facebook.react.bridge.JavaModuleWrapper.invoke JavaModuleWrapper.java:2
com.facebook.react.bridge.queue.NativeRunnable.run NativeRunnable.java
android.os.Handler.handleCallback Handler.java:938
android.os.Handler.dispatchMessage Handler.java:99
com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage MessageQueueThreadHandler.java:1
android.os.Looper.loop Looper.java:246
com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run MessageQueueThreadImpl.java:8
java.lang.Thread.run Thread.java:923
To Reproduce Seems to happen randomly to a few users after 2-3 hours since the app was launched.
Expected behavior App does not crash and plays sound successfully.
Platform (please complete the following information):
- OS: Android
Just noticed the same issue in our app too. Please let us know too, if you've found a solution to this issue
Happened to have the same issue on our app as well. Any solution for this is appreciated. Thanks.
Aslamo Alikm ☺️ I faced the same issue . i find the solution is warp play fn in a settimout .
setTimeout(() => { playSoundRepeatedly(require("./assets/bell.mp3")); }, 1000);
Same issue still exists. In our case it happens when internet connection is abrupt or weak.
any updates on this? We are also facing this issue.
I am also facing the issue.
Context ctx = getCurrentActivity(); if (ctx == null) ctx = getReactApplicationContext(); // this would be the fix wouldnt? mediaPlayer = MediaPlayer.create(ctx, resId);