Crash while read sms on some devices.
I am getting some crashes on some particular device. Here is my crashlytics log :
Fatal Exception: java.lang.NullPointerException: Attempt to invoke interface method 'boolean android.database.Cursor.moveToNext()' on a null object reference
at com.react.SmsModule.list(Unknown Source)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(Unknown Source)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(Unknown Source)
at com.facebook.react.bridge.queue.NativeRunnable.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(Unknown Source)
at android.os.Looper.loop(Looper.java:210)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(Unknown Source)
at java.lang.Thread.run(Thread.java:818)
a solution or workaround would be a great help. Thanks.
Hi @abtuhin. Let me look into it and I'll get back. What Android version is the device running?
Here is the log from crashlytics @briankabiro

Thanks for sending it over. It appears to be occurring because of a null-pointer exception. The solution would be to check if Cursor.moveToNext()!=null before running the code that lists the messages.
I'll see if I can get a fix for it this week.
Cursor.moveToNext()!=null doesn't applicable.
i have tried using while (cursor!=null && cursor.getCount() > 0 && cursor.moveToNext()){...}
And still getting crashes in firebase log @briankabiro
Hmm interesting. Same error still?
Also, apologies. The issue closed automatically after merging the PR
Yes, but i couldn't reproduce this using emulator or any devices. But some users are facing this issue that i can see from crashlytics log. Most of the case it's xioami device or oppo device, version 5
Ok. #21 also lists that there's an issue with getting SMS's on Xiaomi devices.
I have a hunch that it's because the devices run their custom Android OS and there's something that they have that's causing the error.
Hey, @abtuhin.
Have released 1.3.7; is the issue still present?
Sorry for being late to reply @briankabiro I think the issue still exists. This is causing for android version 5 only, some Xioami and OPPO devices
I think the issue still exists.
But we need to know for sure one way or the other. There is a null pointer check in the latest code for the exact object that was null, so I can't understand how it would still happen. It is always possible I am misunderstanding but I would want to know for sure that it is happening after integrating the latest release before spending time on it...
Do you have any ideas how to fix it? I have the same errors