react-native-get-sms-android icon indicating copy to clipboard operation
react-native-get-sms-android copied to clipboard

Crash while read sms on some devices.

Open abtuhin opened this issue 7 years ago • 11 comments

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.

abtuhin avatar Jan 22 '19 11:01 abtuhin

Hi @abtuhin. Let me look into it and I'll get back. What Android version is the device running?

briankabiro avatar Feb 11 '19 10:02 briankabiro

Here is the log from crashlytics @briankabiro

screen shot 2019-02-14 at 12 35 55 pm

abtuhin avatar Feb 14 '19 06:02 abtuhin

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.

briankabiro avatar Feb 20 '19 12:02 briankabiro

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

abtuhin avatar Feb 20 '19 13:02 abtuhin

Hmm interesting. Same error still?

Also, apologies. The issue closed automatically after merging the PR

briankabiro avatar Feb 20 '19 14:02 briankabiro

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

abtuhin avatar Feb 20 '19 19:02 abtuhin

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.

briankabiro avatar Feb 21 '19 07:02 briankabiro

Hey, @abtuhin.

Have released 1.3.7; is the issue still present?

briankabiro avatar Mar 07 '19 10:03 briankabiro

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

abtuhin avatar Mar 27 '19 12:03 abtuhin

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...

mikehardy avatar Mar 27 '19 13:03 mikehardy

Do you have any ideas how to fix it? I have the same errors

SmirnovM91 avatar Feb 22 '20 14:02 SmirnovM91