ryanheise / audio_service

Flutter plugin to play audio in the background while the screen is off.
806 stars 480 forks source link

java.lang.IllegalArgumentException - context shouldn't be null #1051

Closed TheCarpetMerchant closed 11 months ago

TheCarpetMerchant commented 11 months ago

Documented behaviour

audio_service library

Actual behaviour

java.lang.IllegalArgumentException - context shouldn't be null

Runtime error

Fatal Exception: java.lang.RuntimeException: java.lang.IllegalArgumentException: context shouldn't be null
       at com.ryanheise.audioservice.AudioServicePlugin$2.onConnected(AudioServicePlugin.java:89)
       at android.support.v4.media.MediaBrowserCompat$ConnectionCallback$ConnectionCallbackApi21.onConnected(MediaBrowserCompat.java:11)
       at android.media.browse.MediaBrowser$6.run(MediaBrowser.java:602)
       at android.os.Handler.handleCallback(Handler.java:942)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loopOnce(Looper.java:226)
       at android.os.Looper.loop(Looper.java:313)
       at android.app.ActivityThread.main(ActivityThread.java:8810)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

Minimal reproduction project

Official example: main.dart

Reproduction steps

I'm getting this bug from crashlytics, I have no idea what causes it. Could it be that the app gets killed but not the foreground service ?

Output of flutter doctor


    • Flutter version 3.13.9 on channel stable at D:\Code\Flutter\sdk\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision d211f42860 (6 weeks ago), 2023-10-25 13:42:25 -0700
    • Engine revision 0545f8705d
    • Dart version 3.1.5
    • DevTools version 2.25.0

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at C:\Users\user\AppData\Local\Android\sdk
    • Platform android-33, build-tools 30.0.3
    • Java binary at: C:\Program Files\Android\Android Studio 2022\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-10027231)
    • All Android licenses accepted.

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.1.6)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.1.32421.90
    • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2022.3)
    • Android Studio at C:\Program Files\Android\Android Studio 2022
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-10027231)

[√] VS Code (version 1.84.2)
    • VS Code at C:\Users\user\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.44.0

[√] VS Code, 64-bit edition (version 1.79.1)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 3.44.0

[√] Connected device (1 available)
    • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19045.3693]

[√] Network resources
    • All expected network resources are available.

• No issues found!```
### Devices exhibiting the bug
All Android versions, plenty of different differences
ryanheise commented 11 months ago

Minimal reproduction project

Official example: main.dart

Reproduction steps

I'm getting this bug from crashlytics, I have no idea what causes it. Could it be that the app gets killed but not the foreground service ?

I am a bit skeptical that the above is a valid bug report (Why would you run my demo main.dart in production?). Please confirm the correct reproduction project and reproduction steps (otherwise you may close the issue).

TheCarpetMerchant commented 11 months ago

I can't reproduce the issue. I'm looking for pointers on what could be causing this error as it being raised thousands of times points to something being fundamentally wrong in the way I use the plugin, but I have no idea of what it could be.

ryanheise commented 11 months ago

Closing since it is not feasible to fix bugs where no means to reproduce them is provided. As for "looking for pointers", that is not something I dedicate time to - for all I know, you could be running an old version of audio_service with bugs in it that have since been fixed, or you may be doing something else that is not correct according to the documentation, but it's impossible to play this guessing game when you haven't provided the minimal reproduction project for me to inspect. The time for me to investigate a bug is after you submit a valid bug report.

github-actions[bot] commented 11 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs, or use StackOverflow if you need help with audio_service.