[BUG] Playback fails in Release mode on Android (likely AGP 8.7 bug)
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:
- Create a Flutter project using a version compatible with AGP 8.7.0 (e.g., Flutter 3.22.2).
- Add
just_audioandjust_audio_backgrounddependencies. - Attempt to play a plain HTTP audio stream (e.g.,
http://190.128.136.2:8000/stream128). - Build a release APK with
flutter build apk. - Install the generated
app-release.apkon a physical Android device. - Attempt to play the stream. The player will fail.
- 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 inAndroidManifest.xml. - Added comprehensive ProGuard/R8 rules (
-keepand-dontwarn) for Flutter,ryanheise, and all Google/Firebase libraries. - Added a
network_security_config.xmlto explicitly permit cleartext HTTP traffic. - Programmatically set a standard browser User-Agent in the
AudioSourceheaders. 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.
We are also experiencing the exact same issue. Starting with
just_audio: 0.10.0
audio_session 0.2.0
release mode builds do not play URL sourced audio, but it works fine in debug mode. The latest versions of these two packages continue to have the issue.
Simple call in the code that remains unchanged:
await _musicPlayer.setUrl('$musicUrl');
_musicPlayer.play();
Throws a PlayerException of code 2 and message "Unexpected runtime error" in release mode.
From the package versions that introduced the issue, reverting back down one version each to
just_audio: 0.9.46
audio_session: 0.1.25
results in everything working normally again in both debug and release modes.
yes same issue facing with just_audio_background also
i have the same problem ! any fix ?
For me, I've read the documentation in README and the AGP version conflicts with 8.6 and 8.7. I'm at version 8.10.1 so it's irrelevant. Then I looked at this to be added to app/build.gradle:
dependencies { def exoplayer_version = "...specify-version-here...." implementation "com.google.android.exoplayer:exoplayer-core:$exoplayer_version" implementation "com.google.android.exoplayer:exoplayer-dash:$exoplayer_version" implementation "com.google.android.exoplayer:exoplayer-hls:$exoplayer_version" implementation "com.google.android.exoplayer:exoplayer-smoothstreaming:$exoplayer_version" }
and started digging around Android documentation. The latest version of exoplayer is 1.7.1. But the issue is that if you use the above, it's gonna crash in build. So I used:
dependencies { def exoplayer_version = "1.7.1" implementation "androidx.media3:media3-exoplayer:$exoplayer_version" implementation "androidx.media3:media3-exoplayer-dash:$exoplayer_version" implementation "androidx.media3:media3-ui-compose:$exoplayer_version" ... (the rest of your dependencies) }
Exoplayer has moved to a different library Media3.
Need to also add this in android/gradle.properties (if you haven't):
android.useAndroidX=true android.enableJetifier=true
Not sure if you have other types of audioplayers, but I would remove them as they might mess things up.
And of course, the clean up:
flutter clean flutter pub get flutter build appbundle -v
This worked well for me. Just sharing and hope it helps.
I can confirm that this issue occurs with just_audio version 0.10.4. When attempting to load an audio stream URL (which is in my case https), the following error is thrown:
06-18 14:31:59.457 1107 10920 V APM_AudioPolicyManager: getOffloadSupport: profile found 06-18 14:31:59.458 25041 25447 E ExoPlayerImplInternal: Playback error 06-18 14:31:59.458 25041 25447 E ExoPlayerImplInternal: c0.o: Unexpected runtime error 06-18 14:31:59.458 25041 25447 E ExoPlayerImplInternal: at c0.P.handleMessage(SourceFile:309) 06-18 14:31:59.458 25041 25447 E ExoPlayerImplInternal: at android.os.Handler.dispatchMessage(Handler.java:103) 06-18 14:31:59.458 25041 25447 E ExoPlayerImplInternal: at android.os.Looper.loopOnce(Looper.java:257) 06-18 14:31:59.458 25041 25447 E ExoPlayerImplInternal: at android.os.Looper.loop(Looper.java:342) 06-18 14:31:59.458 25041 25447 E ExoPlayerImplInternal: at android.os.HandlerThread.run(HandlerThread.java:85) 06-18 14:31:59.458 25041 25447 E ExoPlayerImplInternal: Caused by: java.lang.NullPointerException 06-18 14:31:59.458 25041 25447 E ExoPlayerImplInternal: at i3.b.getName(Unknown Source:1) 06-18 14:31:59.458 25041 25447 E ExoPlayerImplInternal: at c0.V.h(SourceFile:246) 06-18 14:31:59.458 25041 25447 E ExoPlayerImplInternal: at c0.P.l(SourceFile:34) 06-18 14:31:59.458 25041 25447 E ExoPlayerImplInternal: at c0.P.handleMessage(SourceFile:238) 06-18 14:31:59.458 25041 25447 E ExoPlayerImplInternal: ... 4 more 06-18 14:31:59.459 25041 25041 E AudioPlayer: TYPE_UNEXPECTED: null
To resolve this, I downgraded to just_audio version 0.9.46, which works without issues.
Yes, I am facing same issue, and devoted 1 long day, but still figuring out what happen. Now, just check issue then I got to know. Thank for highlighting this. [EDIT] - downgrading to just_audio version 0.9.46 works.
@DavoFranco , It will be helpful to know what is preventing you from switching to a supported AGP version?
@DavoFranco , It will be helpful to know what is preventing you from switching to a supported AGP version?
Hi Ryan,
Thanks so much for getting back to us and for this great plugin. That's an excellent question, and it's at the core of the issue we're facing.
The reason we are unable to switch to a supported (older) AGP version is a dependency conflict with our Flutter SDK version.
Here's a detailed breakdown of the situation:
-
Flutter Version Constraint: Our project is built on Flutter 3.22.2. This modern version of Flutter requires a correspondingly modern version of the Android Gradle Plugin (AGP) and Gradle itself to build the project correctly.
-
Failed Downgrade Attempt: Following the advice in your documentation, our first instinct was to downgrade to a "safe" AGP version like
8.5.1(which is not affected by the ExoPlayer bug). However, when we do this, the build fails with a clear error:Minimum supported Gradle version is 8.7. Current version is 8.4.This tells us that our Flutter project configuration is incompatible with the older toolchain. We are forced to use a newer version of Gradle, which in turn requires a newer AGP. -
The "Catch-22" Situation: This leaves us trapped in a dependency conflict:
- If we use a modern AGP (like 8.7.0), the project compiles successfully, but we hit the documented bug where ExoPlayer fails at runtime in release mode.
- If we try to use an older, "safe" AGP (like 8.5.1) to avoid the bug, the project fails to compile due to incompatibility with our Flutter SDK's requirements.
We have tried multiple combinations and have also attempted to force a specific, newer version of androidx.media3:media3-exoplayer:1.3.1 in our build.gradle.kts, but the root AGP bug seems to override this fix in release mode.
We understand this is a complex toolchain issue, but any insight or potential workaround you might have would be greatly appreciated. We're happy to help test any potential solutions.
Thank you again for your time.
That answers why you didn't downgrade, but it doesn't answer why you didn't upgrade. You either need to use versions lower than 8.6/8.7, or versions "HIGHER" than 8.6/8.7. But I haven't heard from you why you can't try the latter either, and you are pinned to 8.7.
That answers why you didn't downgrade, but it doesn't answer why you didn't upgrade. You either need to use versions lower than 8.6/8.7, or versions "HIGHER" than 8.6/8.7. But I haven't heard from you why you can't try the latter either, and you are pinned to 8.7.
Hi Ryan,
Thank you for the quick follow-up. That's an excellent question, and my apologies for not being clearer in the initial report.
You are correct, we did not explain why we couldn't upgrade. The simple answer is: we did try upgrading, but the issue persisted.
To be specific:
- Our Flutter version (
3.22.2) forced us to use a newer Gradle version. We upgraded our project to use AGP8.7.0and Gradle8.9. - The project compiled successfully with this newer toolchain.
- However, when we built the release APK and tested it on the physical device, the exact same playback failure occurred. The stream would not play.
This result suggests that the bug might not be limited to just AGP 8.6/8.7, or that it might have another root cause in release builds.
After this failed, we then attempted to downgrade to a "safe zone" like AGP 8.5.1, which is when we ran into the build-time incompatibility with our Flutter version, trapping us in the "catch-22" I described.
I hope this clarifies the situation. It seems we are affected by the bug even on versions higher than 8.7. Thank you again for looking into this.
Thanks for the clarification. I did have someone report that it worked on 8.10 but since you've reported an issue with 8.9 which I was not aware of, I will investigate that. Note that in the pinned issue (from memory), someone also worked around this another way with Proguard rules, so that may be one other aspect to this that I can't see from your project since you didn't submit one in this bug report.
Thanks for the clarification. I did have someone report that it worked on 8.10 but since you've reported an issue with 8.9 which I was not aware of, I will investigate that. Note that in the pinned issue (from memory), someone also worked around this another way with Proguard rules, so that may be one other aspect to this that I can't see from your project since you didn't submit one in this bug report.
Hi Ryan,
Thank you so much for the quick and insightful reply. You were right to ask why we didn't upgrade. Following your suggestion and feedback from the community, we've conducted more tests, and we have a critical new finding.
First, to clarify: We did try upgrading our toolchain to AGP 8.10.1 and Gradle 8.11.1. The project compiled successfully, but unfortunately, the original crash persisted on our test device (Google Pixel 8).
However, following the community's lead, we then focused on more specific ProGuard rules. After many attempts, our latest test yielded a partial, but very revealing, success:
New Finding:
With our current setup (AGP 8.7.0, Gradle 8.9), and after forcing androidx.media3 dependencies and adding specific -keep rules for androidx.media3.extractor.**, we are now seeing this behavior on a release build:
- ABC Radio (HLS Stream): WORKS PERFECTLY. The stream at
https://radiostreaming.abc.com.py/stream/playlist.m3u8now plays without any issues. This confirms our general release setup (permissions, etc.) is correct. - Universo & Monumental (Progressive MP3/AAC Streams): STILL CRASH. The streams at
http://190.128.136.2:8000/stream128etc., now play for about half a second, and then the app crashes.
Conclusion: This strongly suggests the bug is not with the HLS component of ExoPlayer/Media3, but is specifically related to the handling of progressive streams (like MP3/AAC) in release mode under this build configuration. The crash happens right after playback begins.
This seems to be the root cause. We wanted to provide you with this specific feedback, as it might help pinpoint the exact component that is being affected by the R8 optimization.
Thank you again for your time and for this amazing package. We will pause our debugging on this for now and explore other tasks, hoping that a future update might resolve this specific extractor issue.
Thanks for the clarification. I did have someone report that it worked on 8.10 but since you've reported an issue with 8.9 which I was not aware of, I will investigate that. Note that in the pinned issue (from memory), someone also worked around this another way with Proguard rules, so that may be one other aspect to this that I can't see from your project since you didn't submit one in this bug report.
Hi Ryan,
Thank you so much for the quick and insightful reply. You were right to ask why we didn't upgrade. Following your suggestion and feedback from the community, we've conducted more tests, and we have a critical new finding.
First, to clarify: We did try upgrading our toolchain to AGP 8.10.1 and Gradle 8.11.1. The project compiled successfully, but unfortunately, the original crash persisted on our test device (Google Pixel 8).
However, following the community's lead, we then focused on more specific ProGuard rules. After many attempts, our latest test yielded a partial, but very revealing, success:
New Finding: With our current setup (AGP 8.7.0, Gradle 8.9), and after forcing
androidx.media3dependencies and adding specific-keeprules forandroidx.media3.extractor.**, we are now seeing this behavior on a release build:
- ABC Radio (HLS Stream): WORKS PERFECTLY. The stream at
https://radiostreaming.abc.com.py/stream/playlist.m3u8now plays without any issues. This confirms our general release setup (permissions, etc.) is correct.- Universo & Monumental (Progressive MP3/AAC Streams): STILL CRASH. The streams at
http://190.128.136.2:8000/stream128etc., now play for about half a second, and then the app crashes.Conclusion: This strongly suggests the bug is not with the HLS component of ExoPlayer/Media3, but is specifically related to the handling of progressive streams (like MP3/AAC) in release mode under this build configuration. The crash happens right after playback begins.
This seems to be the root cause. We wanted to provide you with this specific feedback, as it might help pinpoint the exact component that is being affected by the R8 optimization.
Thank you again for your time and for this amazing package. We will pause our debugging on this for now and explore other tasks, hoping that a future update might resolve this specific extractor issue.
I seeing the exact same situation here, with one additional clue: In my logs, I consistently see the following warning just before the crash:
W VideoCapabilities: Unrecognized profile/level 32768/256 for video/mp4v-es
This suggests that ExoPlayer might be attempting to switch to a video codec, even though the stream is audio-only. That could explain the half-second playback before the crash occurs on progressive MP3/AAC streams.
[BUG] Playback fails in Release mode on Android (likely AGP 8.7 bug) - FINAL SOLUTION Hi Ryan and everyone,
After an extensive debugging session, we have finally found a stable, multi-part solution that solves all playback issues in release mode on our physical test device (Google Pixel 8, Android 14). The app no longer crashes, and all streams (HLS and Progressive MP3/AAC) play correctly with their corresponding background notifications.
Thank you for your guidance. The issue was a complex combination of the AGP bug, R8 optimization, and server-side stream configurations.
For anyone else facing this issue, here is the complete, step-by-step solution that worked for us:
The Definitive Solution
- Downgrade just_audio and just_audio_background This was the first critical step to avoid the known AGP 8.6/8.7 bug. Reverting to a version family before the issue was introduced proved essential.
File: pubspec.yaml
dependencies: just_audio: ^0.9.46 just_audio_background: ^0.0.1-beta.11
- The Root Cause & Notification Icon Fix Our Crashlytics logs consistently showed a Fatal Exception: java.lang.IllegalArgumentException: Invalid notification (no valid small icon). The crash was not due to audio playback failure, but because the background service could not create the media notification in release mode. The R8 optimizer was likely removing the drawable resource.
The solution was to define the small notification icon directly in the native Android configuration:
File: android/app/src/main/AndroidManifest.xml
<application ...> ... <service android:name="com.ryanheise.audioservice.AudioService" ... >
<!-- This meta-data tag directly tells the native service which drawable to use -->
<meta-data android:name="com.ryanheise.audioservice.android.AndroidAudioService.notification_icon" android:resource="@drawable/ic_stat_notipy"/>
<receiver android:name="com.ryanheise.audioservice.MediaButtonReceiver" ... >
<!-- ... -->
</receiver>
...
- Fix for Progressive Streams (MP3/AAC) We found that HLS streams (like ABC Radio's) worked, but progressive streams (Monumental, Universo) would crash the app. A community member's clue about video codecs was key. The issue was that misconfigured servers were sending video-related headers for audio-only streams.
The fix was to force the server to send proper audio metadata by adding the Icy-MetaData: '1' header to the AudioSource request.
File: your_screen_with_the_player.dart
final Map<String, String> headers = { 'User-Agent': 'Mozilla/5.0 ...', 'Icy-MetaData': '1', };
await _audioPlayer.setAudioSource( AudioSource.uri(Uri.parse(streamUrl), headers: headers), //... );
- Final ProGuard Configuration To ensure R8 doesn't remove any necessary code from the plugins or their dependencies in release mode, this is the final proguard-rules.pro file we are using.
Flutter
-keep class io.flutter.app.** { ; } -keep class io.flutter.plugin.* { ; } -keep class io.flutter.util.* { ; } -keep class io.flutter.view.* { ; } -keep class io.flutter.webkit.* { ; } -keep class io.flutter.embedding.* { *; }
Keep Android entry points
-keep public class * extends android.app.Activity -keep public class * extends android.app.Application -keep public class * extends android.content.BroadcastReceiver -keep public class * extends android.content.ContentProvider -keep public class * extends android.app.Service
just_audio and just_audio_background
-keep class com.ryanheise.audioservice.** { ; } -keep class com.ryanheise.just_audio_service.* { ; } -keepnames class com.ryanheise.audioservice.* { ; } -keepnames class com.ryanheise.just_audio_service.* { ; } -keep class io.flutter.plugins.justaudio.* { ; } -keepnames class io.flutter.plugins.justaudio.* { *; }
Google/Firebase
-dontwarn com.google.firebase.** -dontwarn com.google.android.gms.** -dontwarn com.google.android.play.core.** -keep class com.google.android.gms.** { ; } -keep interface com.google.android.gms.* { ; } -keep class com.google.firebase.* { ; } -keep interface com.google.firebase.* { ; } -keep class com.google.android.play.core.* { ; } -keep interface com.google.android.play.core.* { *; }
Final Conclusion: The issue was a perfect storm. The core problem was the Invalid notification icon crash, which was only happening in release builds due to R8 removing the drawable resource. The streams that used the HLS protocol were robust enough to survive this notification failure (showing a generic notification instead), while the progressive MP3/AAC streams would crash the entire audio service.
By fixing the notification icon directly in the manifest and adding the Icy-MetaData header, all streams now play perfectly in both debug and release builds.
Thank you for your guidance and for this incredible package. I hope this detailed report helps others.
I encountered the same issue where playback fails in release mode on Android - I'm using AGP 8.10. These 2 solutions worked for me:
1. Downgrading the versions to:
just_audio: ^0.9.46
audio_session: ^0.1.25
2. Using the latest versions with proguard-rules:
pubspec.yaml:
audio_session: ^0.2.2
just_audio: ^0.10.4
proguard-rules.pro:
-keep class com.ryanheise.just_audio.** { *; }
Same here: Playback fails on some devices, though the app plays audio files from assets only.
Downgrading to just_audio: 0.9.46 and adding -keep class com.ryanheise.just_audio.** { *; } to proguard-rules.pro doesn't solve the issue - at least not on a Pixel 9 Pro XL and Pixel 8A running Android 16 and Samsung Galaxy S24 (SM-S921B) running Android 15.
BTW, remove ^ in front of the version number if you want to downgrade!
Since there is more activity on this, I will take another look into this again, but on my end, I do not experience any issues when avoiding AGP 8.6/8.7 as per the instructions.
Reading back what @DavoFranco wrote earlier:
You are correct, we did not explain why we couldn't upgrade. The simple answer is: we did try upgrading, but the issue persisted.
To be specific:
* Our Flutter version (`3.22.2`) forced us to use a newer Gradle version. We upgraded our project to use **AGP `8.7.0`** and **Gradle `8.9`**. * The project compiled successfully with this newer toolchain. * However, when we built the release APK and tested it on the physical device, the exact same playback failure occurred. The stream would not play.
Reading this more carefully, aren't you saying that you upgraded your project to use one of the version that I blacklisted? i.e. You upgraded to use AGP 8.7 which was the version that I identified as one that you need to avoid.
So, I am reopening my investigation, here, but I need someone to provide a reproduction outside of the two blacklisted AGP versions. Can anyone provide a reproduction either below AGP 8.6 or above 8.7?
Perhaps @mgcaguioa you are closest to being able to provide that, since you said you were using AGP 8.10. Are you able to provide me with a reproduction that I can test on? If I can verify that your particular example reproduces the issue, I will be able to investigate it a bit more and try to find a solution that does not require a workaround.
@ryanheise Is this fixed in new release ?
@ycv005 all development is done in the open, changes that are part of a release are mentioned in the CHANGELOG, and developments related to this issue are all openly discussed in the comments. If you scroll up, you will see that nobody has replied to my last comment, so there have been no new developments since then.
If you are experiencing the issue, please provide what I am asking for and I can then investigate it.
One slightly new development, however, is that Flutter will be dropping support for AGP 8.5.2 soon, so I am less concerned about reproductions below 8.6, and more interested in reproductions above AGP 8.7.
Hi, I'm also having this issue. It happens with gradle 8.13, 8.10.2, and presumably in between versions as well. Only happens in release mode. No special setup is necessary, just loading an audio source in a blank project causes it. On the flutter ndk version no error is thrown, on 27.0.12077973 this is the stack trace:
E/flutter (11459): [ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: (0) Source error
E/flutter (11459): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:652)
E/flutter (11459): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:370)
E/flutter (11459): <asynchronous suspension>
E/flutter (11459): #2 MethodChannelAudioPlayer.load (package:just_audio_platform_interface/method_channel_just_audio.dart:58)
E/flutter (11459): <asynchronous suspension>
E/flutter (11459): #3 AudioPlayer._load.<anonymous closure> (package:just_audio/just_audio.dart:1018)
E/flutter (11459): <asynchronous suspension>
E/flutter (11459): #4 AudioPlayer._load (package:just_audio/just_audio.dart:1019)
E/flutter (11459): <asynchronous suspension>
E/flutter (11459): #5 AudioPlayer._setPlatformActive.setPlatform (package:just_audio/just_audio.dart:1755)
E/flutter (11459): <asynchronous suspension>
E/flutter (11459): #6 AudioPlayer._setPlatformActive.<anonymous closure> (package:just_audio/just_audio.dart:1769)
E/flutter (11459): <asynchronous suspension>
E/flutter (11459): #7 AudioPlayer.load (package:just_audio/just_audio.dart:926)
E/flutter (11459): <asynchronous suspension>
E/flutter (11459): #8 AudioPlayer.setAudioSources (package:just_audio/just_audio.dart:897)
E/flutter (11459): <asynchronous suspension>
E/flutter (11459): #9 main.<anonymous closure> (package:just_audio_test/main.dart:12)
E/flutter (11459): <asynchronous suspension>
Reproduction repo: https://github.com/Lojcs/just_audio_test/
I have added the following to my proguard-rules.pro and it runs smoothly now, just a workaround
# just_audio / ExoPlayer / Media3
-keep class androidx.media3.** { *; }
-dontwarn androidx.media3.**
-keep class com.google.android.exoplayer2.** { *; }
-dontwarn com.google.android.exoplayer2.**
At least in my case this isn't a proguard related issue as I don't use it and it happens in a fresh project as well.
At least in my case this isn't a proguard related issue as I don't use it and it happens in a fresh project as well.
ProGuard (or R8 in newer Gradle builds) works by shrinking and obfuscating your code. During this process, it can sometimes remove or rename classes that libraries like ExoPlayer/Media3 rely on, which leads to runtime crashes even if the app builds fine.
Even if you’re not explicitly enabling ProGuard in your project, some build variants (like release) might still run with minification. To rule that out, you could try adding these rules to your proguard-rules.pro file:
# just_audio / ExoPlayer / Media3
-keep class androidx.media3.** { *; }
-dontwarn androidx.media3.**
-keep class com.google.android.exoplayer2.** { *; }
-dontwarn com.google.android.exoplayer2.**
That way, the required classes won’t get stripped or obfuscated. If the issue still happens after adding these, then we can be more confident it’s unrelated to ProGuard.
This works, thank you. I stand corrected. Perhaps this could be included in the plugin.
Reproduction repo: https://github.com/Lojcs/just_audio_test/
I believe the playback issue in this test project was caused by a missing android.permission.INTERNET entry in the AndroidManifest.xml file.
i.e.
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
...
Hm, yes and no. The permission was missing, but adding only the permission doesn't fix the issue. The proguard-rules.pro file also needs to be added. Updated the repo with the permission
Forget everything I said, this is the AGP 8.7 bug. Since this page comes up as the first search result when searching how to upgrade Flutter AGP versions and it only explains upgrading the Gradle version, I had assumed the AGP version must be dependent on the Gradle version. When AGP is actually upgraded the app works fine without the proguard-rules.pro file. I apologize for cluttering the issue.
Even if you’re not explicitly enabling ProGuard in your project, some build variants (like release) might still run with minification. To rule that out, you could try adding these rules to your proguard-rules.pro file:
Just to be sure when you say this, do you mean the file in android/app/?
I did not have any proguard-rules.pro file in my project upon creation, so far I have tried adding it to android/app/proguard-rules.pro without any other modification and it didn't fix the issue, I'm wondering if I have to mention this file into android/app/build.gradle maybe?
I still can't make the streamed audio work with setUrl even though I am using the downgraded versions of the dependencies. I can't provide the code right now as it's still closed source, but I will share it as soon as possible