briankabiro / react-native-get-sms-android

React Native module to get messages on an Android device
MIT License
136 stars 68 forks source link

Crash while read sms on some devices. #20

Open abtuhin opened 5 years ago

abtuhin commented 5 years ago

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.

briankabiro commented 5 years ago

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

abtuhin commented 5 years ago

Here is the log from crashlytics @briankabiro

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

briankabiro commented 5 years ago

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.

abtuhin commented 5 years ago

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

briankabiro commented 5 years ago

Hmm interesting. Same error still?

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

abtuhin commented 5 years ago

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

briankabiro commented 5 years ago

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 commented 5 years ago

Hey, @abtuhin.

Have released 1.3.7; is the issue still present?

abtuhin commented 5 years ago

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

mikehardy commented 5 years ago

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

SmirnovM91 commented 4 years ago

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