Kotlin plugin error: Could not generate a proxy class for class org.jetbrains.kotlin.gradle.tasks.KotlinCompile

Viewed 11046

Getting an error while trying to run a gradle task. Can't figure out what else is required or what the error is about. The project I'm working on has several subprojects, so I have a main build.gradle. The error is for a subproject where I wanted to try Kotlin.

* Where: Build file '/home/oracle/bnc/KotlinHandler/build.gradle' line: 13

* What went wrong: A problem occurred evaluating root project 'KotlinHandler'.
> Failed to apply plugin [id 'kotlin']
   > Could not generate a proxy class for class org.jetbrains.kotlin.gradle.tasks.KotlinCompile.

Here is my build.gradle for the failing module (sub-project).

buildscript {
    ext.kotlin_version = '1.1.2-2'

    repositories {
        mavenCentral()
    }

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

apply plugin: 'kotlin'

repositories {
    mavenCentral()
}

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}

Here is Pastebin build.gradle which is quite big, because of all the tasks in it

Added --debug output after changing jdk to 1.8 and compile dependency to compile "org.jetbrains.kotlin:kotlin-stdlib-jre8

4 Answers

If you're still receiving this error despite:

  • Setting the JAVA_HOME environment variable to your JDK8 installation.
  • Changing sourceCompatibility in your build.gradle file.
  • Pointing to JDK8 in your gradle.properties file.

It's possible that you're running an old version of gradle.

I was receiving this error on gradle version 3.2, but upgrading to version 5.1 fixed the error for me.

You can download the latest release from Gradle's Website.

More info here.

Related