ryanheise / audio_service

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

Compilation error in AudioService.java (Flutter plugin audio_service 0.18.15) when running ./gradlew build --refresh-dependencies #1095

Open ChrisZi opened 1 month ago

ChrisZi commented 1 month ago

Minimal reproduction project

Official example: main.dart

Build command

./gradlew build --refresh-dependencies

Build error

F:\flutter\.pub-cache\hosted\pub.dev\audio_service-0.18.15\android\src\main\java\com\ryanheise\audioservice\AudioService.java:389:
Error: Must be one of: Service.STOP_FOREGROUND_LEGACY, Service.STOP_FOREGROUND_REMOVE, Service.STOP_FOREGROUND_DETACH [WrongConstant]
              stopForeground(removeNotification ? STOP_FOREGROUND_REMOVE : 0);

Output of flutter doctor

[√] Flutter (Channel stable, 3.24.3, on Microsoft Windows [Version 10.0.19045.4894], locale pl-PL)
    • Flutter version 3.24.3 on channel stable at C:\src\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2663184aa7 (3 weeks ago), 2024-09-11 16:27:48 -0500
    • Engine revision 36335019a8
    • Dart version 3.5.3
    • DevTools version 2.37.3

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

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at C:\Android\android-sdk
    • Platform android-35, build-tools 34.0.0
    • ANDROID_HOME = C:\Android\android-sdk
    • Java binary at: C:\Users\user\AppData\Local\Programs\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 21.0.3+-12282718-b509.11)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Build Tools 2019 16.11.27)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools
    • Visual Studio Build Tools 2019 version 16.11.33801.447
    • Windows 10 SDK version 10.0.22621.0

[!] Android Studio (version 4.0)
    • Android Studio at C:\Program Files\Android\Android Studio
    • 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
    X Unable to determine bundled Java version.
    • Try updating or re-installing Android Studio.

[√] Android Studio (version 2024.1)
    • Android Studio at C:\Users\user\AppData\Local\Programs\Android Studio 2
    • 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.11+0--11852314)

[√] Android Studio (version 2024.2)
    • Android Studio at C:\Users\user\AppData\Local\Programs\Android Studio
    • 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 21.0.3+-12282718-b509.11)

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

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.19045.4894]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 129.0.6668.89
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 128.0.2739.42

[√] Network resources
    • All expected network resources are available.
pro100svitlo commented 3 weeks ago

I am facing the same problem even with audio_service: 0.18.10

Dmitriy1902 commented 2 weeks ago

I have the same problem(