[BUG] AndroidAlarmManager.initialize messes up flutter_sound recording/playing
See original GitHub issueFlutter Sound Version :
- flutter_sound: ^4.0.0
Severity
- Crash
Platforms you faced the error
- Android Emulator
Logs
E/MethodChannel#com.dooboolab.flutter_sound_player( 9765): java.lang.NullPointerException: Attempt to invoke virtual method 'void com.dooboolab.fluttersound.FlutterSoundPlayer.stopPlayer(io.flutter.plugin.common.MethodCall, io.flutter.plugin.common.MethodChannel$Result)' on a null object reference
E/MethodChannel#com.dooboolab.flutter_sound_player( 9765): at com.dooboolab.fluttersound.FlautoPlayerPlugin.onMethodCall(FlutterSoundPlayer.java:167)
E/MethodChannel#com.dooboolab.flutter_sound_player( 9765): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:231)
E/MethodChannel#com.dooboolab.flutter_sound_player( 9765): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:93)
E/MethodChannel#com.dooboolab.flutter_sound_player( 9765): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:642)
E/MethodChannel#com.dooboolab.flutter_sound_player( 9765): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#com.dooboolab.flutter_sound_player( 9765): at android.os.MessageQueue.next(MessageQueue.java:336)
E/MethodChannel#com.dooboolab.flutter_sound_player( 9765): at android.os.Looper.loop(Looper.java:174)
E/MethodChannel#com.dooboolab.flutter_sound_player( 9765): at android.app.ActivityThread.main(ActivityThread.java:7356)
E/MethodChannel#com.dooboolab.flutter_sound_player( 9765): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#com.dooboolab.flutter_sound_player( 9765): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/MethodChannel#com.dooboolab.flutter_sound_player( 9765): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
I/flutter ( 9765): PlatformException(error, Attempt to invoke virtual method 'void com.dooboolab.fluttersound.FlutterSoundPlayer.stopPlayer(io.flutter.plugin.common.MethodCall, io.flutter.plugin.common.MethodChannel$Result)' on a null object reference, null)
E/MethodChannel#com.dooboolab.flutter_sound_player( 9765): Failed to handle method call
E/MethodChannel#com.dooboolab.flutter_sound_player( 9765): java.lang.NullPointerException: Attempt to invoke virtual method 'void com.dooboolab.fluttersound.FlutterSoundPlayer.startPlayer(io.flutter.plugin.common.MethodCall, io.flutter.plugin.common.MethodChannel$Result)' on a null object reference
E/MethodChannel#com.dooboolab.flutter_sound_player( 9765): at com.dooboolab.fluttersound.FlautoPlayerPlugin.onMethodCall(FlutterSoundPlayer.java:155)
E/MethodChannel#com.dooboolab.flutter_sound_player( 9765): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:231)
E/MethodChannel#com.dooboolab.flutter_sound_player( 9765): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:93)
E/MethodChannel#com.dooboolab.flutter_sound_player( 9765): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:642)
E/MethodChannel#com.dooboolab.flutter_sound_player( 9765): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#com.dooboolab.flutter_sound_player( 9765): at android.os.MessageQueue.next(MessageQueue.java:336)
E/MethodChannel#com.dooboolab.flutter_sound_player( 9765): at android.os.Looper.loop(Looper.java:174)
E/MethodChannel#com.dooboolab.flutter_sound_player( 9765): at android.app.ActivityThread.main(ActivityThread.java:7356)
E/MethodChannel#com.dooboolab.flutter_sound_player( 9765): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#com.dooboolab.flutter_sound_player( 9765): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/MethodChannel#com.dooboolab.flutter_sound_player( 9765): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
I/flutter ( 9765): Play error: Exception: PlatformException(error, Attempt to invoke virtual method 'void com.dooboolab.fluttersound.FlutterSoundPlayer.startPlayer(io.flutter.plugin.common.MethodCall, io.flutter.plugin.common.MethodChannel$Result)' on a null object reference, null)
or with recorder:
E/MethodChannel#com.dooboolab.flutter_sound_recorder( 9908): java.lang.NullPointerException: Attempt to invoke virtual method 'void com.dooboolab.fluttersound.FlutterSoundRecorder.isEncoderSupported(io.flutter.plugin.common.MethodCall, io.flutter.plugin.common.MethodChannel$Result)' on a null object reference
E/MethodChannel#com.dooboolab.flutter_sound_recorder( 9908): at com.dooboolab.fluttersound.FlautoRecorderPlugin.onMethodCall(FlutterSoundRecorder.java:149)
E/MethodChannel#com.dooboolab.flutter_sound_recorder( 9908): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:231)
E/MethodChannel#com.dooboolab.flutter_sound_recorder( 9908): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:93)
E/MethodChannel#com.dooboolab.flutter_sound_recorder( 9908): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:642)
E/MethodChannel#com.dooboolab.flutter_sound_recorder( 9908): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#com.dooboolab.flutter_sound_recorder( 9908): at android.os.MessageQueue.next(MessageQueue.java:336)
E/MethodChannel#com.dooboolab.flutter_sound_recorder( 9908): at android.os.Looper.loop(Looper.java:174)
E/MethodChannel#com.dooboolab.flutter_sound_recorder( 9908): at android.app.ActivityThread.main(ActivityThread.java:7356)
E/MethodChannel#com.dooboolab.flutter_sound_recorder( 9908): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#com.dooboolab.flutter_sound_recorder( 9908): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/MethodChannel#com.dooboolab.flutter_sound_recorder( 9908): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
I/flutter ( 9908): startRecording error: PlatformException(error, Attempt to invoke virtual method 'void com.dooboolab.fluttersound.FlutterSoundRecorder.isEncoderSupported(io.flutter.plugin.common.MethodCall, io.flutter.plugin.common.MethodChannel$Result)' on a null object reference, null)
flutter pub deps :
dependencies:
flutter:
sdk: flutter
english_words: 3.1.5
flutter_sound: ^4.0.0
provider: ^4.0.4
path_provider: ^1.6.5
android_alarm_manager: ^0.4.5
Describe the bug
I tried to use FlutterSoundRecorder
and FlutterSoundPlayer
and all worked fine until I tried to use android_alarm_manager
. After this flutter_sound
always crashes with the above exception.
To Reproduce Steps to reproduce the behavior:
- Having your usual code that uses
await _player.startPlayer(filePath)
or recorder, and all works fine. - Add
android_alarm_manager: ^0.4.5
topubspec.yaml
. - Execute
await AndroidAlarmManager.initialize();
somewhere in your code. - You will get one of the above exceptions.
Expected behavior Sound plays or message recorded.
Possible reasons
Something happens with static data in Android implementation of flutter_sound
, it becomes null
, for example, slots
on https://github.com/dooboolab/flutter_sound/blob/master/android/src/main/java/com/dooboolab/fluttersound/FlutterSoundPlayer.java#L76
Forgot to say: thanks for taking your time checking this! 😃
Issue Analytics
- State:
- Created 3 years ago
- Comments:7
Top Results From Across the Web
[BUG] AndroidAlarmManager.initialize messes up ... - GitHub
Yes, it is possible that it is related. Several issues have been reported on Android about Flutter Sound compatibility with other plugins doing ......
Read more >Android Alarm Manager is not working for Flutter Project App
I tried using the example code of Plugin, but it gives an error in console. Please suggest how to make the Android Alarm...
Read more >android_alarm_manager_plus | Flutter Package - Pub.dev
A Flutter plugin for accessing the Android AlarmManager service, and running Dart code in the background when alarms fire.
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
Yes, it is possible that it is related. Several issues have been reported on Android about Flutter Sound compatibility with other plugins doing things with services.
We are actually working on a new version of Flutter Sound which will not use Services on Android. This version is supposed to be released next week. I really bet that this release will solve this issue.
Any updates regarding this issue @Larpoux ?