Why I am getting this error after Flutter Run?

Viewed 641

I am getting the following Build failed with exception after I run my flutter project.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class com.google.android.exoplayer2.ui.DownloadNotificationHelper found in modules jetified-exoplayer-core-2.17.0-runtime (com.google.android.exoplayer:exoplayer-core:2.17.0) and jetified-exoplayer-ui-2.15.1-runtime (com.google.android.exoplayer:exoplayer-ui:2.15.1)

     Go to the documentation to learn how to <a href="d.android.com/r/tools/classpath-sync-errors">Fix dependency resolution errors</a>.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3m 26s
Running Gradle task 'assembleDebug'...                            208.9s
Exception: Gradle task assembleDebug failed with exit code 1

I am currently using Flutter's latest version that is Version 2.10.1. Also in my project, I used the 'better_player' pub package.

Please give me a solution to this.

2 Answers

Add following dependency in app/build.gradle in dependencies at the end of the file -

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

Example -

dependencies {

    ...

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

}

First : if you are using video_player add this line in your app/build.gradle

implementation 'com.google.android.exoplayer:exoplayer:2.17.1'

Second : if you are using better_player add this line in your app/build.gradle

implementation 'com.google.android.exoplayer:exoplayer:2.15.0'

Third : if you are using the both video_player & better_player you should downgraded video_player version to 2.1.12 in pubspec.yaml

Related