[BUG]: Context.startForegroundService() did not then call Service.startForeground():
See original GitHub issueFlutter Sound Version :
-
LITE
-
Important: Result of the command :
flutter pub deps | grep flutter_sound
|-- flutter_sound_lite 8.4.1
| |-- flutter_sound_platform_interface 8.4.1
| |-- flutter_sound_web 8.4.1
| | |-- flutter_sound_platform_interface...
Severity
-Crashes with the error :
/AndroidRuntime(31243): Shutting down VM
E/AndroidRuntime(31243): FATAL EXCEPTION: main
E/AndroidRuntime(31243): Process: com.ryanheise.audioserviceexample, PID: 31243
E/AndroidRuntime(31243): android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{7519a88 u0 com.ryanheise.audioserviceexample/com.dooboolab.TauEngine.FlautoBackgroundAudioService}
E/AndroidRuntime(31243): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2188)
E/AndroidRuntime(31243): at android.os.Handler.dispatchMessage(Handler.java:107)
E/AndroidRuntime(31243): at android.os.Looper.loop(Looper.java:237)
E/AndroidRuntime(31243): at android.app.ActivityThread.main(ActivityThread.java:8167)
E/AndroidRuntime(31243): at java.lang.reflect.Method.invoke(Native Method)
-
Result is not what expected ? Dont expect that just by adding the plugin flutter sound lite will crash the same audio service example
-
Cannot build my App ? Ok - can build but we get a warning on build :
WARNING: [Processor] Library '/.gradle/caches/modules-2/files-2.1/com.github.canardoux/flutter_sound_core/8.4.1/df1da2efb4085098ab4cd8d45dc76626f0f6da3a/flutter_sound_core-8.4.1.aar' contains references to both AndroidX and old support library. This seems like the library is partially migrated. Jetifier will try to rewrite the library anyway.
Example of androidX reference: 'androidx/arch/core/util/Function'
Example of support library reference: 'android/support/v4/media/session/MediaSessionCompat$Callback'
- Minor issue ? No - Major as adding Flutter_Sound_Lite increases RAM usage
Platforms you faced the error
- Android
- Real device ? Yes , Samsung S10+
Describe the bug When you run the sample audio service here and then interface with the front screen controls (press pause, stop button etc a few times) - app crashes and we get the stack trace shown.
To Reproduce Steps to reproduce the behavior:
- Fork or run the sample app of audio_service https://github.com/ryanheise/audio_service/blob/07313c1aaee4551333bac3d8a9ab6198ac495b81/audio_service/example/lib/example_multiple_handlers.dart
- Modify the pubspec.yaml to be :
path_provider: ^2.0.1
audio_session: 0.1.6+1
just_audio: 0.9.12
flutter_tts: 3.2.2
rxdart: ^0.27.2
audio_service: 0.18.0
flutter_sound_lite: 8.4.1
i.e we have just added flutter_sound_lite 8.4.1
- Build and run your app for Android on Simulator or Live device.
- On the main screen of your devices, press the PAUSE button a few times and then STOP -> Your app crashes.
Logs!!!
We only include Flutter_sound_lite in pubspec.yaml. No class from Flutter_Sound_Lite is used or instantiated in this example.
Issue Analytics
- State:
- Created 2 years ago
- Comments:34
Top Results From Across the Web
Context.startForegroundService() did not then call Service ...
I was calling startForeground in onStartCommand(), and I was occasionally getting this error. I moved it to onCreate and I haven't seen it...
Read more >Context.startForegroundService() Did Not Then Call Service ...
Adding a startForeground() command, with notification, right at the beginning of the onStartCommand method of foreground service. Adding ...
Read more >Context.startForegroundService() did not then call Service ...
I am following the documentation for every call of startForegroundService I am calling startForeground in onStartCommand method. It seems there is OS bug...
Read more >Context.startForegroundService() did not then call Service ...
If I run the app with mobile phone which is active (display ON), then I dont get this this error. I am using...
Read more >Context.startForegroundService() did not then call Service ...
startForeground(). from the CommonsWare Community archives. At September 7, 2019, 7:34am, rd7773 asked: I am starting foreground service from MainActivity's ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Larpoux In order to allow myself and others (@sallypeters) to continue working, it should be possible to easily create a fork of
flutter_sound
and remove the conflicting Android definitions for Lockscreen/notification. Can you please give some basic guidelines how to do it? I will share the fork here so others can use it until issue is resolved in the correct manner. Thanks!@Larpoux I have just came across the same problem; Our project uses
flutter_sound
for recording (to a stream, not a file) and for ffmpeg operations (Audio conversions), and we wanted to introduceaudio_service
to support background playback (LockScreen/Notification functionality). To the best of my understanding it would be best ifflutter_sound
plugin can be split into smaller pieces, so the each developer can use those building blocks as he wishes. Does the latest version offlutter_sound
support LockScreen/Notification functionality?