Skip to content

[BUG] Playback fails in Release mode on Android (likely AGP 8.7 bug) #1506

@DavoFranco

Description

@DavoFranco

Which API doesn't behave as documented, and how does it misbehave?
The audioPlayer.setAudioSource API fails to play plain HTTP streams when the application is built in release mode (flutter build apk). The player enters an error state. The exact same code and stream URL work perfectly when the app is run in debug mode (flutter run) on the same physical device.

Minimal reproduction project
We have not been able to isolate this into a minimal project due to the complexity of the build environment dependencies. The issue appears to be a direct result of the documented conflict between our Flutter version (which requires a modern AGP) and the just_audio/ExoPlayer bug on AGP 8.6/8.7. We believe any project using this toolchain combination and attempting to play a plain HTTP stream in release mode will encounter this issue.

To Reproduce (i.e. user steps, not code)
Steps to reproduce the behavior:

  1. Create a Flutter project using a version compatible with AGP 8.7.0 (e.g., Flutter 3.22.2).
  2. Add just_audio and just_audio_background dependencies.
  3. Attempt to play a plain HTTP audio stream (e.g., http://190.128.136.2:8000/stream128).
  4. Build a release APK with flutter build apk.
  5. Install the generated app-release.apk on a physical Android device.
  6. Attempt to play the stream. The player will fail.
  7. Run the same project in debug mode on the same device. The stream plays correctly.

Error messages

There is no direct crash log from Flutter, as it's a native playback failure. The player state stream reports an error, and the UI shows a "Failed to load stream" message. This only happens in release builds.

Expected behavior
The stream should play correctly in release mode, just as it does in debug mode.

Smartphone (please complete the following information):

  • Device: Google Pixel 8
  • OS: Android 14+

Flutter SDK version

[√] Flutter (Channel stable, 3.32.2, on Microsoft Windows [Versi¢n 10.0.26100.4351], locale es-PY)
    • Flutter version 3.32.2 on channel stable at C:\FlutterSDK\flutter
    • Upstream repository [https://github.com/flutter/flutter.git](https://github.com/flutter/flutter.git)
    • Framework revision 8defaa71a7 (12 days ago), 2025-06-04 11:02:51 -0700
    • Engine revision 1091508939
    • Dart version 3.8.1
    • DevTools version 2.45.1
[√] Windows Version (11 Pro 64-bit, 24H2, 2009)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Platform android-35, build-tools 34.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13368085-b895.109)
    • All Android licenses accepted.
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.7.3)
[√] Android Studio (version 2024.3.2)
[√] VS Code (version 1.100.2)
[√] Connected device (4 available)
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64    • Android 16 (API 36) (emulator)
    • Windows (desktop)           • windows       • windows-x64    • Microsoft Windows [Versi¢n 10.0.26100.4351]
    • Chrome (web)                • chrome        • web-javascript • Google Chrome 137.0.7151.104
    • Edge (web)                  • edge          • web-javascript • Microsoft Edge 137.0.3296.68
[√] Network resources
    • All expected network resources are available.
• No issues found!

Additional context
We have already tried all common solutions without success:

  • Confirmed all necessary permissions (INTERNET, WAKE_LOCK, FOREGROUND_SERVICE, etc.) are in AndroidManifest.xml.
  • Added comprehensive ProGuard/R8 rules (-keep and -dontwarn) for Flutter, ryanheise, and all Google/Firebase libraries.
  • Added a network_security_config.xml to explicitly permit cleartext HTTP traffic.
  • Programmatically set a standard browser User-Agent in the AudioSource headers.
    The issue seems to be a hard conflict between Flutter's requirement for a modern AGP and the documented bug in AGP 8.6/8.7 that affects ExoPlayer in release mode.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions