Search code examples
javagradleintellij-ideabuild.gradlegradle-plugin

Gradle version/ Gradle JVM is compatible with JDK, still receiving Unsupported class major file version 61 error


I already have checked this IntelliJ gradle project error "Unsupported class file major version 61" and unfortunately it couldn't solve my problem.

I am using Intellij-idea. I check Oracle documentation to find out that Java 15.0.2 is compatible with Gradle version 6.7, still I am receiving Unsupported class major file version 61.

Also I was previously using JDK 17 but then I have uninstalled it, and also set Java_Home to JDK 15.

The details of Gradle version downloaded on my PC

------------------------------------------------------------
Gradle 6.7
------------------------------------------------------------

Build time:   2020-10-14 16:13:12 UTC
Revision:     312ba9e0f4f8a02d01854d1ed743b79ed996dfd3

Kotlin:       1.3.72
Groovy:       2.5.12
Ant:          Apache Ant(TM) version 1.10.8 compiled on May 10 2020
JVM:          15.0.2 (Oracle Corporation 15.0.2+7-27)
OS:           Windows 10 10.0 amd64

The details of JDK am using:

java version "15.0.2" 2021-01-19
Java(TM) SE Runtime Environment (build 15.0.2+7-27)
Java HotSpot(TM) 64-Bit Server VM (build 15.0.2+7-27, mixed mode, sharing)

I have Double checked Project Structure >> Project >> JDK version am using, it is also 15.

I also double checked Settings >> Build Tools >> Gradle >> Gradle JVM which is also 15.

I also double checked gradle >> gradle-wrapper.properties file to see if version is 6.7 there, it was 7.5.1 but I fixed it to 6.7 (saw this upon searching on stackOverflow, i hope it is right way to do this)

distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip

I also changed target and source compatability to 15 as following:

 // Set the JVM compatibility versions
    withType<JavaCompile> {
        sourceCompatibility = "15"
        targetCompatibility = "15"

Despite it all, am still receiving this error. How to fix this?

After updating Intellij to 2023.1.2

  1. Gradle Wrapper properties:

    distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists distributionUrl=https://services.gradle.org/distributions/gradle- 7.6-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists

  2. Plugin & dependencies section:

    plugins { id("java") id("org.jetbrains.intellij") version "1.14.1" }

    group = "com.plugin" version = "1.0-SNAPSHOT"

    repositories { mavenCentral() }

    // Configure Gradle IntelliJ Plugin // Read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html intellij { version.set("2023.1.2") type.set("IC") // Target IDE Platform

     plugins.set(listOf(/* Plugin Dependencies */))
    

    }

    tasks { // Set the JVM compatibility versions withType { sourceCompatibility = "20" targetCompatibility = "20" }

     patchPluginXml {
         sinceBuild.set("221")
         untilBuild.set("231.*")
     }
    
     signPlugin {
         certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
         privateKey.set(System.getenv("PRIVATE_KEY"))
         password.set(System.getenv("PRIVATE_KEY_PASSWORD"))
     }
    
     publishPlugin {
         token.set(System.getenv("PUBLISH_TOKEN"))
     }
    

    }


Solution

  • The only way it got solved is: Updated Intellij to the latest version (2023.1.2) Added Gradle 8.1.1 (latest gradle version yet) Using latest JDK & JVM (20)