[FLUTTER-Android] Build Failure due to Deprecated ExoPlayer, Migration to AndroidX Media3 Needed
Which API doesn't behave as documented, and how does it misbehave? Hi, I'm currently using the just_audio package in my Flutter application. However, I'm facing a build failure when running the app on an Android device. It appears the issue is due to the AudioPlayer class in the just_audio package relying on deprecated ExoPlayer imports. After researching this issue, I found that Google suggests migrating from ExoPlayer to AndroidX Media3. This migration is essential because the current ExoPlayer imports are deprecated and no longer compatible with the latest Android standards. Could you please consider updating the just_audio package to use AndroidX Media3? This change would resolve the build issues and ensure compatibility with the latest Android versions. Thank you for your support and for maintaining this valuable package.
Minimal reproduction project Provide a link here using one of two options: Any project that contains just_audio package!
To Reproduce (i.e. user steps, not code) Steps to reproduce the behavior:
- Create a new Flutter project or open an existing one.
- Import the latest version of the just_audio package from https://pub.dev/packages/just_audio.
- In the build.gradle file located at your_project_root/android/app/, set minSdkVersion to 24 and targetSdkVersion to 34
- Execute the flutter run command to build and run the app.
- Observe that the build fails, displaying errors related to deprecated file paths.
Error messages
/.pub-cache/hosted/pub.dev/just_audio-0.9.36/android/src/main/java/com/ryanheise/just_audio/AudioPlayer.java:559: warning: [deprecation] ConcatenatingMediaSource in com.google.android.exoplayer2.source has been deprecated private ConcatenatingMediaSource concatenating(final Object index) { ^ /.pub-cache/hosted/pub.dev/just_audio-0.9.36/android/src/main/java/com/ryanheise/just_audio/AudioPlayer.java:560: warning: [deprecation] ConcatenatingMediaSource in com.google.android.exoplayer2.source has been deprecated return (ConcatenatingMediaSource)mediaSources.get((String)index); ^ /.pub-cache/hosted/pub.dev/just_audio-0.9.36/android/src/main/java/com/ryanheise/just_audio/AudioPlayer.java:566: warning: [deprecation] MediaSource in com.google.android.exoplayer2.source has been deprecated MediaSource mediaSource = mediaSources.get(id); ^ /.pub-cache/hosted/pub.dev/just_audio-0.9.36/android/src/main/java/com/ryanheise/just_audio/AudioPlayer.java:570: warning: [deprecation] ConcatenatingMediaSource in com.google.android.exoplayer2.source has been deprecated ConcatenatingMediaSource concatenatingMediaSource = (ConcatenatingMediaSource)mediaSource; ^ /.pub-cache/hosted/pub.dev/just_audio-0.9.36/android/src/main/java/com/ryanheise/just_audio/AudioPlayer.java:570: warning: [deprecation] ConcatenatingMediaSource in com.google.android.exoplayer2.source has been deprecated ConcatenatingMediaSource concatenatingMediaSource = (ConcatenatingMediaSource)mediaSource; ^ /.pub-cache/hosted/pub.dev/just_audio-0.9.36/android/src/main/java/com/ryanheise/just_audio/AudioPlayer.java:583: warning: [deprecation] MediaSource in com.google.android.exoplayer2.source has been deprecated private MediaSource getAudioSource(final Object json) { ^ /.pub-cache/hosted/pub.dev/just_audio-0.9.36/android/src/main/java/com/ryanheise/just_audio/AudioPlayer.java:586: warning: [deprecation] MediaSource in com.google.android.exoplayer2.source has been deprecated MediaSource mediaSource = mediaSources.get(id); ^ /.pub-cache/hosted/pub.dev/just_audio-0.9.36/android/src/main/java/com/ryanheise/just_audio/AudioPlayer.java:594: warning: [deprecation] DefaultExtractorsFactory in com.google.android.exoplayer2.extractor has been deprecated private DefaultExtractorsFactory buildExtractorsFactory(Map options) { ^ /.pub-cache/hosted/pub.dev/just_audio-0.9.36/android/src/main/java/com/ryanheise/just_audio/AudioPlayer.java:595: warning: [deprecation] DefaultExtractorsFactory in com.google.android.exoplayer2.extractor has been deprecated DefaultExtractorsFactory extractorsFactory = new DefaultExtractorsFactory(); ^ /.pub-cache/hosted/pub.dev/just_audio-0.9.36/android/src/main/java/com/ryanheise/just_audio/AudioPlayer.java:595: warning: [deprecation] DefaultExtractorsFactory in com.google.android.exoplayer2.extractor has been deprecated DefaultExtractorsFactory extractorsFactory = new DefaultExtractorsFactory(); ^ /.pub-cache/hosted/pub.dev/just_audio-0.9.36/android/src/main/java/com/ryanheise/just_audio/AudioPlayer.java:613: warning: [deprecation] MediaSource in com.google.android.exoplayer2.source has been deprecated private MediaSource decodeAudioSource(final Object json) { ^ /.pub-cache/hosted/pub.dev/just_audio-0.9.36/android/src/main/java/com/ryanheise/just_audio/AudioPlayer.java:618: warning: [deprecation] ProgressiveMediaSource in com.google.android.exoplayer2.source has been deprecated return new ProgressiveMediaSource.Factory(buildDataSourceFactory(mapGet(map, "headers")), buildExtractorsFactory(mapGet(map, "options")))
Expected behavior The expectation is that the Flutter app should build successfully and run without any issues on an Android device. The just_audio package should integrate seamlessly with the project, and there should be no build failures due to deprecated file paths or compatibility issues with the Android SDK versions specified.
Screenshots Nope 🙌
Desktop (please complete the following information):
- OS: Mac
- Browser : Chrome
Smartphone (please complete the following information):
- Device: Android simulator / iPhone 14
- OS: Android
Flutter SDK version
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0-rc2)
[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2023.3.2)
[✓] Connected device (4 available)
[✓] Network resources
Additional context Flutter 3.16.5 • channel stable • https://github.com/flutter/flutter.git Framework • revision 78666c8dc5 (3 weeks ago) • 2023-12-19 16:14:14 -0800 Engine • revision 3f3e560236 Tools • Dart 3.2.3 • DevTools 2.28.4
Thank you for the report. I believe this is important but your bug report is unreadable as it does not follow the format required by my instructions. Please provide everything requested in the format requested so that I can proceed.
Hi @ryanheise I’ve updated the issue description and error 🙌🏾
Still not correct. You deleted the triple backticks before and after the error message. You also didn't fill in the 2 sections correctly for the minimal reproduction project.
Closing as no response. No reproduction project was provided, and I cannot reproduce it. If anyone encounters the same issue, please open a new bug report as such an error would be treated as a high priority to investigate.
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 just_audio.