hanatharesh2712 / ionic-native-sms-retriever-plugin-master

Cross-platform plugin for Cordova / PhoneGap to Retrieve SMS. Available for Android.
27 stars 18 forks source link

Crash - caused by onDestroy - Receiver not Registered #15

Closed orenagiv closed 3 years ago

orenagiv commented 4 years ago

Hey,

In some cases a crash occurs (we don't have specific steps to reproduce): Fatal Exception: java.lang.RuntimeException Unable to destroy activity {app.tabit.il_prd/app.tabit.il_prd.MainActivity}: java.lang.IllegalArgumentException: Receiver not registered: com.codingsans.ionic.smsRetriever.AndroidSmsRetriever$3@d15f808

It's caused by: com.codingsans.ionic.smsRetriever.AndroidSmsRetriever.onDestroy (AndroidSmsRetriever.java:122)

image

It seems that onDestroy it tries to unregister, but if the receiver is not registered - it causes the app to crash.

hanatharesh2712 commented 4 years ago

@orenagiv Thanks for using the plugin! Can you send me the environment details like Cordova, ionic and device version? it will help me to reproduce the issue. Thanks!

orenagiv commented 4 years ago

Hey @hanatharesh2712, Thanks for the quick response!

We're using Cordova 9.0.0 (not ionic). Cordova-android v8.1.0 is used.

The device versions that encountered this issue in our case are: Galaxy S10 | Android 10 Pixel 4 | Android 10 Galaxy S9 | Android 9 Galaxy A70 | Android 9 Galaxy S8 | Android 9 Galaxy S7 Edge | Android 8.0.0

Is there any other information you need?

orenagiv commented 4 years ago

Hey @hanatharesh2712, Did you get a chance to look at this one?

Thanks! Oren

EinfachHans commented 4 years ago

Appeared to me also. 3 Times currently

hanatharesh2712 commented 4 years ago

@orenagiv @HansKrywaa I have tried to reproduce this issue with the environment you said. (with Ionic) and I can't reproduce this issue. I tried this on different emulators and a real Samsung device.

If you guys can have some specific steps to reproduce then It will be good to have for debugging. Thanks!

EinfachHans commented 4 years ago

@hanatharesh2712 - i can't reproduce it voa steps, but crash still occurs. Isn't it possible to add a workaround by just checking if Receiver is registered?

hanatharesh2712 commented 4 years ago

@HansKrywaa I am already checking that onDestoy method. I will wrap unregister code in try-catch block to avoid crash.

hanatharesh2712 commented 4 years ago

@orenagiv @HansKrywaa I have updated the code and published the package. please try with installing the latest

EinfachHans commented 3 years ago

I will use the Fix in our next Release and let you know if it happens again

orenagiv commented 3 years ago

Thanks @hanatharesh2712 ! I'll test and let you know.

EinfachHans commented 3 years ago

Didn't happen for me again, what about you @orenagiv ?

orenagiv commented 3 years ago

Hey @HansKrywaa I couldn't reproduce it locally, and we haven't yet deployed a new release to production. However, we are going to release one within a few days - and then I'll monitor it and update you here.

Thanks for all your efforts! 👍

hanatharesh2712 commented 3 years ago

closing this as resolved. if you have still issues then open it again.

ferfrasa commented 2 years ago

Hello, I have been testing these days the plugin with a cordova application and I am getting the same error message, I already have the latest version of the plugin where you added try catch.

Plugin : Cordova vesion 10.0.0. "cordova-android": "^9.1.0", cordova-plugin-sms-retriever-manager 1.0.3 "Device"

I try in android studio emulator

samgbg

java.lang.IllegalArgumentException: Receiver not registered: com.codingsans.ionic.smsRetriever.AndroidSmsRetriever$3@cf10c27 at android.app.LoadedApk.forgetReceiverDispatcher(LoadedApk.java:1435) 2022-04-06 16:48:20.885 4724-4724/W/System.err: at android.app.ContextImpl.unregisterReceiver(ContextImpl.java:1642) 2022-04-06 16:48:20.885 4724-4724/: at android.content.ContextWrapper.unregisterReceiver(ContextWrapper.java:715) 2022-04-06 16:48:20.885 4724-4724/ W/System.err: at com.codingsans.ionic.smsRetriever.AndroidSmsRetriever.onDestroy(AndroidSmsRetriever.java:122)

I really appreciate your help