Gradle Project: java.lang.NoClassDefFoundError: kotlin/jvm/internal/Intrinsics

前端 未结 8 1503
抹茶落季
抹茶落季 2020-12-14 14:50

I\'m working on a Java project and within this project I did my first try with Kotlin. I started converting some classes to Kotlin with the JavaToKoltin converter provided i

8条回答
  •  天命终不由人
    2020-12-14 15:31

    Adding all project files to the jar fixed the problem for me. I added the following line to my build.gradle

    jar {
        manifest {
            attributes ...
        }
        // This line of code recursively collects and copies all of a project's files
        // and adds them to the JAR itself. One can extend this task, to skip certain
        // files or particular types at will
        from { configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
    }
    

    Update: Changed configurations.compile.collect to configurations.compileClasspath.collect according to this answer below.

提交回复
热议问题