Zionnite
Zionnite

Reputation: 463

Flutter App Crash Unexpectedly because of Flutter Background

I have some issues with my Flutter Android app, every time I run and build the app, it crashes, I guess it has to do with the Flutter background dependencies i add to the pubspec.yaml file

Package of Interest

  flutter_background_service: ^5.0.5
  flutter_background: ^1.2.0
  flutter_ringtone_player: ^3.2.0
  flutter_webrtc: ^0.9.35
  firebase_core: ^2.24.2
  cloud_firestore: ^4.14.0
  firebase_messaging: ^14.7.10
  firebase_database: ^10.4.0
  awesome_notifications_core: ^0.9.1 
  awesome_notifications: any

enter image description here enter image description here enter image description here enter image description here Error

D/FlutterWebRTCPlugin(17231): Stopping the audio manager...
D/AndroidRuntime(17231): Shutting down VM
E/AndroidRuntime(17231): FATAL EXCEPTION: main
E/AndroidRuntime(17231): Process: com.xxxx.xxxx, PID: 17231
E/AndroidRuntime(17231): android.app.RemoteServiceException$ForegroundServiceDidNotStartInTimeException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{5b24383 u0 com.zioninvasion.prayer_buddy/id.flutter.flutter_background_service.BackgroundService}
E/AndroidRuntime(17231):    at android.app.ActivityThread.generateForegroundServiceDidNotStartInTimeException(ActivityThread.java:2104)
E/AndroidRuntime(17231):    at android.app.ActivityThread.throwRemoteServiceException(ActivityThread.java:2075)
E/AndroidRuntime(17231):    at android.app.ActivityThread.-$$Nest$mthrowRemoteServiceException(Unknown Source:0)
E/AndroidRuntime(17231):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2369)
E/AndroidRuntime(17231):    at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(17231):    at android.os.Looper.loopOnce(Looper.java:205)
E/AndroidRuntime(17231):    at android.os.Looper.loop(Looper.java:294)
E/AndroidRuntime(17231):    at android.app.ActivityThread.main(ActivityThread.java:8177)
E/AndroidRuntime(17231):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(17231):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
E/AndroidRuntime(17231):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
E/AndroidRuntime(17231): Caused by: android.app.StackTrace: Last startServiceCommon() call for this service was made here
E/AndroidRuntime(17231):    at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1952)
E/AndroidRuntime(17231):    at android.app.ContextImpl.startForegroundService(ContextImpl.java:1906)
E/AndroidRuntime(17231):    at android.content.ContextWrapper.startForegroundService(ContextWrapper.java:830)
E/AndroidRuntime(17231):    at androidx.core.content.ContextCompat$Api26Impl.startForegroundService(ContextCompat.java:1189)
E/AndroidRuntime(17231):    at androidx.core.content.ContextCompat.startForegroundService(ContextCompat.java:752)
E/AndroidRuntime(17231):    at id.flutter.flutter_background_service.FlutterBackgroundServicePlugin.start(FlutterBackgroundServicePlugin.java:82)
E/AndroidRuntime(17231):    at id.flutter.flutter_background_service.FlutterBackgroundServicePlugin.onMethodCall(FlutterBackgroundServicePlugin.java:121)
E/AndroidRuntime(17231):    at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
E/AndroidRuntime(17231):    at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/AndroidRuntime(17231):    at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:322)
E/AndroidRuntime(17231):    at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/AndroidRuntime(17231):    at android.os.Handler.handleCallback(Handler.java:958)
E/AndroidRuntime(17231):    at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(17231):    ... 6 more
I/Process (17231): Sending signal. PID: 17231 SIG: 9
Lost connection to device.

Upvotes: 0

Views: 1452

Answers (1)

Zionnite
Zionnite

Reputation: 463

I was having this issue because I targeted SDK Version 34, and by the time I downgraded it to 33 my problem was resolved

Upvotes: 0

Related Questions