close

[Solved] Gradle “Entry .classpath is a duplicate but no duplicate handling strategy has been set”

Hello Guys, How are you all? Hope You all Are Fine. Today I am facing the following error Gradle “Entry .classpath is a duplicate but no duplicate handling strategy has been set” in Java. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Gradle “Entry .classpath is a duplicate but no duplicate handling strategy has been set” Error Occurs?

Today I am facing the following error Gradle “Entry .classpath is a duplicate but no duplicate handling strategy has been set” in Java.

How To Solve Gradle “Entry .classpath is a duplicate but no duplicate handling strategy has been set” Error ?

  1. How To Solve Gradle “Entry .classpath is a duplicate but no duplicate handling strategy has been set” Error ?

    To Solve Gradle “Entry .classpath is a duplicate but no duplicate handling strategy has been set” Error If you use Kotlin DSL and Gradle 7.0 it may be due to that bug KT-46165 It should be fixed in version 1.5.0.

  2. Gradle “Entry .classpath is a duplicate but no duplicate handling strategy has been set”

    To Solve Gradle “Entry .classpath is a duplicate but no duplicate handling strategy has been set” Error If you use Kotlin DSL and Gradle 7.0 it may be due to that bug KT-46165 It should be fixed in version 1.5.0.

Solution 1

I solved mine using the EXCLUDE Strategy;

tasks.withType<Jar>() {

    duplicatesStrategy = DuplicatesStrategy.EXCLUDE

    manifest {
        attributes["Main-Class"] = "MainKt"
    }

    configurations["compileClasspath"].forEach { file: File ->
        from(zipTree(file.absoluteFile))
    }
}

Solution 2

If you use Kotlin DSL and Gradle 7.0 it may be due to that bug KT-46165 It should be fixed in version 1.5.0.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read