Flutter better_player android Duplicate class found in modules jetified-exoplayer-core-2.17.0-runtime.jar and jetified-exoplayer-ui-2.15.1-runtime.jar

Viewed 2298

When running Flutter build apk with version 0.0.81 the following error is thrown

1 exception was raised by workers: java.lang.RuntimeException: Duplicate class com.google.android.exoplayer2.ui.DownloadNotificationHelper found in modules jetified-exoplayer-core-2.17.0-runtime.jar (com.google.android.exoplayer:exoplayer-core:2.17.0) and jetified-exoplayer-ui-2.15.1-runtime.jar (com.google.android.exoplayer:exoplayer-ui:2.15.1)[BUG]

I tried to exclude the module and group in android's build.gradle and still it does not work. My pubspec.yaml environment: sdk: ">=2.7.0 <3.0.0"

So how can I use better_player: 0.0.81

5 Answers

Had the same issue, apparently the issue is that I was using video_player (2.3.0) and better_player (0.0.81). video_player depends on exoplayer 2.17 while better_player depends on exoplayer 2.15. I downgraded video_player to 2.1.12 (in pubspec.yaml you may need to write video_player: 2.1.12 WITHOUT ^).

Fixed it by adding

implementation ('com.google.android.exoplayer:exoplayer:2.17.0') 

at dependencies in /android/app/build.gradle

dependencies {
    ....
    implementation ('com.google.android.exoplayer:exoplayer:2.17.0')
}

In my case it was resolved with:

  • In pubspec.yaml, if you have both better_player and video_player in the project, you need to reduce the video_player version to 2.1.12, so that there is no conflict between the better_player internal video_player version.

This worked for me. Hope it helps more people!

Had the same issue and I solve it by using an old version of pubspec.lock and cleaning the cache with flutter clean and flutter pub cache clean and running flutter pub get

If you have the Chewie package installed, it might cause an issue because it depends on a non-compatible version of video_player. Better Player works with video_player 2.1.12. I was having a hard time finding this solution since the error I was debugging was <aynschronous suspension> when initiating BetterPlayer, however this is the solution I just confirmed it.

Related