Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

gradle

kotlin

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

like image 952
Philipp Grigoryev Avatar asked May 20 '17 15:05

Philipp Grigoryev


3 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.

like image 179
byxor Avatar answered Nov 20 '22 02:11

byxor


starting kotlin 1.1.2 JDK below 1.8 is not supported anymore by the kotlin compiler as in 1.1.2 blog post:

The Kotlin compiler now requires JDK 8 to run. You shouldn’t notice any changes, because most other Java development tools such as Gradle and the Android toolchain also require JDK 8, so you almost certainly already have it installed. For code generated by the compiler, Java 1.6 compatibility is still the default, and we have no plans to drop support for generating Java 1.6 compatible bytecode.

like image 7
oshai Avatar answered Nov 20 '22 03:11

oshai


In my case, it was because I was running gradle with java 1.7 and it looks like the plugin was compiled only for 1.8:

16:48:42.742 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id 'kotlin']
16:48:42.742 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:153)
16:48:42.742 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:112)
16:48:42.742 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyType(DefaultObjectConfigurationAction.java:113)
16:48:42.742 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:36)
16:48:42.742 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:80)
16:48:42.742 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:136)
16:48:42.742 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:46)
16:48:42.742 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.java:34)
16:48:42.742 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.Script$apply$1.callCurrent(Unknown Source)
16:48:42.742 [ERROR] [org.gradle.BuildExceptionReporter]        at build_4u37tyfuy0k7d4zd8vsk5lx9d.run(build.gradle:17)
16:48:42.743 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:91)
16:48:42.743 [ERROR] [org.gradle.BuildExceptionReporter]        ... 63 more
16:48:42.743 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: org.gradle.api.GradleException: Could not generate a proxy class for class org.jetbrains.kotlin.gradle.tasks.KotlinCompile.
16:48:42.743 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.AbstractClassGenerator.generateUnderLock(AbstractClassGenerator.java:201)
16:48:42.743 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.AbstractClassGenerator.generate(AbstractClassGenerator.java:64)
16:48:42.743 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.project.taskfactory.TaskFactory.create(TaskFactory.java:115)
16:48:42.743 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.project.taskfactory.TaskFactory.createTask(TaskFactory.java:77)
16:48:42.743 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory.createTask(AnnotationProcessingTaskFactory.java:101)
16:48:42.743 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.project.taskfactory.DependencyAutoWireTaskFactory.createTask(DependencyAutoWireTaskFactory.java:39)
16:48:42.743 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.tasks.DefaultTaskContainer.create(DefaultTaskContainer.java:62)
16:48:42.743 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.tasks.DefaultTaskContainer.create(DefaultTaskContainer.java:97)
16:48:42.743 [ERROR] [org.gradle.BuildExceptionReporter]        at org.jetbrains.kotlin.gradle.tasks.KotlinTasksProvider.createKotlinJVMTask(TasksProvider.kt:26)
16:48:42.743 [ERROR] [org.gradle.BuildExceptionReporter]        at org.jetbrains.kotlin.gradle.plugin.Kotlin2JvmSourceSetProcessor.doCreateTask(KotlinPlugin.kt:111)
16:48:42.744 [ERROR] [org.gradle.BuildExceptionReporter]        at org.jetbrains.kotlin.gradle.plugin.Kotlin2JvmSourceSetProcessor.doCreateTask(KotlinPlugin.kt:93)
16:48:42.744 [ERROR] [org.gradle.BuildExceptionReporter]        at org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetProcessor.createKotlinCompileTask(KotlinPlugin.kt:83)
16:48:42.744 [ERROR] [org.gradle.BuildExceptionReporter]        at org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetProcessor.<init>(KotlinPlugin.kt:56)
16:48:42.744 [ERROR] [org.gradle.BuildExceptionReporter]        at org.jetbrains.kotlin.gradle.plugin.Kotlin2JvmSourceSetProcessor.<init>(KotlinPlugin.kt:101)
16:48:42.744 [ERROR] [org.gradle.BuildExceptionReporter]        at org.jetbrains.kotlin.gradle.plugin.KotlinPlugin.buildSourceSetProcessor$kotlin_gradle_plugin_main(KotlinPlugin.kt:302)
16:48:42.744 [ERROR] [org.gradle.BuildExceptionReporter]        at org.jetbrains.kotlin.gradle.plugin.KotlinPlugin.buildSourceSetProcessor$kotlin_gradle_plugin_main(KotlinPlugin.kt:295)
16:48:42.744 [ERROR] [org.gradle.BuildExceptionReporter]        at org.jetbrains.kotlin.gradle.plugin.AbstractKotlinPlugin$configureSourceSetDefaults$1.execute(KotlinPlugin.kt:279)
16:48:42.744 [ERROR] [org.gradle.BuildExceptionReporter]        at org.jetbrains.kotlin.gradle.plugin.AbstractKotlinPlugin$configureSourceSetDefaults$1.execute(KotlinPlugin.kt:256)
16:48:42.744 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.DefaultDomainObjectCollection.all(DefaultDomainObjectCollection.java:110)
16:48:42.745 [ERROR] [org.gradle.BuildExceptionReporter]        at org.jetbrains.kotlin.gradle.plugin.AbstractKotlinPlugin.configureSourceSetDefaults(KotlinPlugin.kt:278)
16:48:42.745 [ERROR] [org.gradle.BuildExceptionReporter]        at org.jetbrains.kotlin.gradle.plugin.AbstractKotlinPlugin.apply(KotlinPlugin.kt:269)
16:48:42.745 [ERROR] [org.gradle.BuildExceptionReporter]        at org.jetbrains.kotlin.gradle.plugin.KotlinPlugin.apply(KotlinPlugin.kt:306)
16:48:42.745 [ERROR] [org.gradle.BuildExceptionReporter]        at org.jetbrains.kotlin.gradle.plugin.KotlinPlugin.apply(KotlinPlugin.kt:295)
16:48:42.745 [ERROR] [org.gradle.BuildExceptionReporter]        at org.jetbrains.kotlin.gradle.plugin.KotlinBasePluginWrapper.apply(KotlinPluginWrapper.kt:46)
16:48:42.745 [ERROR] [org.gradle.BuildExceptionReporter]        at org.jetbrains.kotlin.gradle.plugin.KotlinBasePluginWrapper.apply(KotlinPluginWrapper.kt:34)
16:48:42.745 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.plugins.ImperativeOnlyPluginApplicator.applyImperative(ImperativeOnlyPluginApplicator.java:35)
16:48:42.745 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.plugins.RuleBasedPluginApplicator.applyImperative(RuleBasedPluginApplicator.java:43)
16:48:42.745 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:137)
16:48:42.745 [ERROR] [org.gradle.BuildExceptionReporter]        ... 73 more
16:48:42.745 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.lang.UnsupportedClassVersionError: org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments : Unsupported major.minor version 52.0
16:48:42.745 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.internal.reflect.ClassInspector.inspectClass(ClassInspector.java:67)
16:48:42.745 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.internal.reflect.ClassInspector.visitGraph(ClassInspector.java:51)
16:48:42.745 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.internal.reflect.ClassInspector.inspect(ClassInspector.java:31)
16:48:42.746 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.AbstractClassGenerator.inspectType(AbstractClassGenerator.java:260)
16:48:42.746 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.AbstractClassGenerator.inspectType(AbstractClassGenerator.java:216)
16:48:42.746 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.AbstractClassGenerator.generateUnderLock(AbstractClassGenerator.java:95)

Related tickets: https://youtrack.jetbrains.com/issue/KT-17866 and https://youtrack.jetbrains.com/issue/KT-17297

like image 3
Daniel Silva Avatar answered Nov 20 '22 03:11

Daniel Silva