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

This error is likely due to the fact that the simple jar task doesn’t take all its runtime dependencies.

From gradle documentation, In your build.gradle.kts you can either create a "fatJar" task or add that to your jar task:

tasks.withType<Jar> {
    // Otherwise you'll get a "No main manifest attribute" error
    manifest {
        attributes["Main-Class"] = "com.example.MainKt"
    }

    // To add all of the dependencies
    from(sourceSets.main.get().output)

    dependsOn(configurations.runtimeClasspath)
    from({
        configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it) }
    })
}

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.


I'm going to say that you're trying to run Kotlin code without the kotlin-runtime library

Check which system you're using and add the neccesary jar file. You can verify that this is your issue by packaging your project into a .jar file and running it with the runtime library


You need to configure your project with kotlin. So in Android Studio:

  1. click on Tools => kotlin => Configure kotlin in project

  2. Then in dialog check : All module containing kotlin files

  3. and select version

  4. press ok

Done.