Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] IncomingSmsReceiver listening even when instance is not created leading to crashing of app when a background notification recieves #184

Open
loud-at-heart opened this issue Mar 7, 2023 · 1 comment

Comments

@loud-at-heart
Copy link

Your Environment

  • Plugin version: ^0.2.0
  • Platform: Android
  • OS version: 12 and higher
  • Device manufacturer / model: all
  • Flutter info (flutter info, flutter doctor):
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.0.5, on macOS 13.0.1 22A400 darwin-arm (Rosetta), locale en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] VS Code (version 1.74.0)
[✓] VS Code (version 1.61.1)
[✓] Connected device (3 available)
[✓] HTTP Host Availability
  • Plugin config
telephony.listenIncomingSms(
        onNewMessage: onMessage,
        onBackgroundMessage: onBackgroundMessage,
      );

To Reproduce
Steps to reproduce the behavior (keep eye on Logcat):

  1. Install the app with the plugin and move the app to background
  2. Send a random message to your respective contact number
  3. Check the console logs

Debug logs

# Crashlytics - Stack trace
# Platform: android
# Date: Tue Mar 07 2023 15:58:20 GMT+0530 (India Standard Time)

Fatal Exception: java.lang.RuntimeException: Unable to start receiver com.shounakmulay.telephony.sms.IncomingSmsReceiver: java.lang.NullPointerException: Attempt to read from field 'java.lang.String io.flutter.view.FlutterCallbackInformation.callbackLibraryPath' on a null object reference in method 'java.lang.String io.flutter.embedding.engine.dart.DartExecutor$DartCallback.toString()'
       at android.app.ActivityThread.handleReceiver(ActivityThread.java:4770)
       at android.app.ActivityThread.access$1700(ActivityThread.java:310)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2292)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:226)
       at android.os.Looper.loop(Looper.java:313)
       at android.app.ActivityThread.main(ActivityThread.java:8663)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

Caused by java.lang.NullPointerException: Attempt to read from field 'java.lang.String io.flutter.view.FlutterCallbackInformation.callbackLibraryPath' on a null object reference in method 'java.lang.String io.flutter.embedding.engine.dart.DartExecutor$DartCallback.toString()'
       at io.flutter.embedding.engine.dart.DartExecutor$DartCallback.toString(DartExecutor.java:421)
       at java.lang.String.valueOf(String.java:3657)
       at java.lang.StringBuilder.append(StringBuilder.java:132)
       at io.flutter.embedding.engine.dart.DartExecutor.executeDartCallback(DartExecutor.java:175)
       at com.shounakmulay.telephony.sms.IncomingSmsHandler.startBackgroundIsolate(IncomingSmsHandler.kt:154)
       at com.shounakmulay.telephony.sms.IncomingSmsReceiver.processInBackground(IncomingSmsHandler.kt:95)
       at com.shounakmulay.telephony.sms.IncomingSmsReceiver.processIncomingSms(IncomingSmsHandler.kt:82)
       at com.shounakmulay.telephony.sms.IncomingSmsReceiver.onReceive(IncomingSmsHandler.kt:50)
       at android.app.ActivityThread.handleReceiver(ActivityThread.java:4761)
       at android.app.ActivityThread.access$1700(ActivityThread.java:310)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2292)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:226)
       at android.os.Looper.loop(Looper.java:313)
       at android.app.ActivityThread.main(ActivityThread.java:8663)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

Additional context
This issue is happening because we are registering the broadcast receiver in Android Manifest, so on install itself the broadcast receiver is registered and starts receiving SMS , which actually should be registered when we want to listen for any incoming message

@Coder-Manuel
Copy link

Am facing the same issue especially with newer android devices.
Any fix available yet for this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants