question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] AndroidAlarmManager.initialize messes up flutter_sound recording/playing

See original GitHub issue

Flutter 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:

  1. Having your usual code that uses await _player.startPlayer(filePath) or recorder, and all works fine.
  2. Add android_alarm_manager: ^0.4.5 to pubspec.yaml.
  3. Execute await AndroidAlarmManager.initialize(); somewhere in your code.
  4. 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:open
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
Larpouxcommented, Jan 22, 2022

Just curious, is this issue somehow related? 😃 #340

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.

0reactions
AbdullahLabib22commented, Jun 22, 2022

Any updates regarding this issue @Larpoux ?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found