1

When I want to start my app, I get this error message:

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 kotlin.collections.jdk8.CollectionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0)
     Duplicate class kotlin.internal.jdk8.JDK8PlatformImplementations found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0)
     Duplicate class kotlin.jvm.jdk8.JvmRepeatableKt found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0)
     Duplicate class kotlin.random.jdk8.PlatformThreadLocalRandom found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0)
     Duplicate class kotlin.streams.jdk8.StreamsKt found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0)
     Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$1 found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0)
     Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$2 found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0)
     Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$3 found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0)
     Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$4 found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0)
     Duplicate class kotlin.text.jdk8.RegexExtensionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0)
     Duplicate class kotlin.time.jdk8.DurationConversionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0)

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

I tried to restart my pc and flutter clean but that didnt work.

ex0
  • 13
  • 3

3 Answers3

0

Welcome to StackOverflow.

Actual solution: A failure occurred while executing app:checkDebugDuplicateClasses

Possible solution 1
Your description is insufficient for anyone to tell what might be wrong with your application, except that you might be defining an existing class name.

If you are sure you didn't override any Dart class name, and if you are using Visual Studio Code, try to delete your ".dart_tool" folder from your project.

Then you need to run the flutter pub get to fix all your dependencies and rebuild the necessary folders.

Possible solution 2
You might have a library conflict, try to remove some of the latest packages you've added, to figure out which ones are conflicting with each other.

Canilho
  • 944
  • 5
  • 11
  • I commented 2 packages and the methods that used those packages but it still doesnt really work :/ – ex0 Aug 21 '23 at 16:40
  • I dont think that overrid any dart class name – ex0 Aug 21 '23 at 16:46
  • Try if you can open a different project (it can be a new one) and try to build it. If you still have any errors, you might have a Java JDK conflict. – Canilho Aug 21 '23 at 16:53
  • I started a new app but it doesnt have errors. I'm using flutter, dart. Can a java jdk conflict really be possible? – ex0 Aug 21 '23 at 18:05
  • If you have no errors with a new project, then no... You don't have any Java conflicts. The most probable cause is the libraries you are using, or your code has duplicated class names. – Canilho Aug 21 '23 at 18:07
  • Check if this solves your issue: https://stackoverflow.com/a/75315276/4605422 – Canilho Aug 21 '23 at 18:11
  • Now I get a new Error message xD – ex0 Aug 21 '23 at 18:57
  • 1
    Now it works, thanks for the link, the new error came up because i deleted a kotlin folder from the project which included the mainactivity file – ex0 Aug 22 '23 at 07:34
0

I think inside android/app/src/main/java there is a main file and also inside android/app/src/main/kotlin there is a main file. So the flutter framework is now confused which entry point should be used as both of them have the same name but in different language. Just remove one of the file and it shoudld work.

Or, you are using 2 versions of JDKs, just remove one of them

Abhishek Doshi
  • 465
  • 2
  • 5
0

A solution that worked for me:

Look at the error message:

Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules 
    jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10)
 and 
    jetified-kotlin-stdlib-jdk8-1.6.0 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0)

Note that one version of the library is 1.8.10 and another one is 1.6.0.

Now go to your android/build.gradle file. Your ext.kotlin_version line in there is probably set to 1.6.0, change it to 1.8.10 (or the other way around).

enzo
  • 9,861
  • 3
  • 15
  • 38