How To Fix “ERROR : ‘compileJava’ task (current target is 11) and ‘compileKotlin’ task (current target is 1.8) jvm target compatibility should be set to the same Java version”?
Are you having problems with the issue “ERROR : ‘compileJava’ task (current target is 11) and ‘compileKotlin’ task (current target is 1.8) jvm target compatibility should be set to the same Java version“? How to fix it? In today’s article, I will provide solutions for you to solve the issues. Please follow the below steps to get the problem resolved now
How did “ERROR : ‘compileJava’ task (current target is 11) and ‘compileKotlin’ task (current target is 1.8) jvm target compatibility should be set to the same Java version” occur?
ERROR : ‘compileJava’ task (current target is 11) and ‘compileKotlin’ task (current target is 1.8) jvm target compatibility should be set to the same Java version
When you work with JAVA, you may get the issue ERROR : ‘compileJava’ task (current target is 11) and ‘compileKotlin’ task (current target is 1.8) jvm target compatibility should be set to the same Java version. Don’t worry, we are here to provide you solutions in order to resolve your problem.
How to fix “ERROR : ‘compileJava’ task (current target is 11) and ‘compileKotlin’ task (current target is 1.8) jvm target compatibility should be set to the same Java version”?
ERROR: The ‘compileJava task (currently target is 11) as well as the ‘compileKotpn task (currently target is 1.8), jvm target compatibility should be set to the identical Java version. To do this, simply pke this. Now, your error must be fixed.
Solution 1: Just set java version
Simply set the Java version for Java as follows.
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
Now, your error must be fixed.
Solution 2: This is the solution
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(11))
}
Solution 3: For kotlin
Set jvmTarget if you are using Kotlin. This is how it works.
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
jvmTarget = "11"
}
}
Final words
The above are useful solutions that can help you fix “ERROR : ‘compileJava’ task (current target is 11) and ‘compileKotlin’ task (current target is 1.8) jvm target compatibility should be set to the same Java version” problem, if you can’t solve it well. Please leave a message.