0

BUG! exception in phase 'semantic analysis' in source unit 'BuildScript' Unsupported class file major version 61

enter image description here

Uzbekjon
  • 11,655
  • 3
  • 37
  • 54

1 Answers1

2

I got this yesterday too. Check the version of Gradle you are using vs the version of the JDK.

Since you're not using the Gradle wrapper, maybe for you it's just a matter of upgrading Gradle and/or the JDK.

I was using the Gradle wrapper so it's a bit different, but essentially the problem was that I updated my wrapper properties to Gradle 7.3.3, but the currently downloaded gradle was still the old one (too old) which was not compatible with my JDK 17.

For some reason, I needed to configure Gradle in IDEA to use the properties file instead of the wrapper task for it to work:

gradle settings menu dropdown

gradle settings wrapper properties

Joffrey
  • 32,348
  • 6
  • 68
  • 100
  • I got this problem when I wanted to try Kotlin/Compose on my windows computer. I followed https://github.com/JetBrains/compose-jb/tree/master/tutorials/Getting_Started and installed latest version of jdk and IntelliJ IDEA. When I tried to set use 'grade-wrapper.properties' I got error that the file doesn't exist. Instead I had to set Gradle JVM to version 11.0.12 which was already installed. – j.karlsson Feb 26 '22 at 09:17
  • Hm, I still can't get it to work. After changes done in my previous comment I can build. But when I try to run I get this error: "> Process 'command 'C:\Program Files\Microsoft\jdk-11.0.12.7-hotspot\bin\java.exe'' finished with non-zero exit value 1" IntelliJ/Gradle/Kotlin/Compose/What-ever seems to be a real mess... – j.karlsson Feb 26 '22 at 09:58
  • I was finally able to solve the problems, see my answer at https://stackoverflow.com/questions/69425829/unsupported-class-file-major-version-61-error/71276762#71276762 – j.karlsson Feb 26 '22 at 12:49