Unsupported Class File Major Version 61 Error
I Am Trying to Run a Flutter App, and This Error Appeared While Trying To, What I Did Was That I Wanted to Run Flutter Apps Without Android Studio, So I...
I am trying to run a flutter app, and this error appeared while trying to, what I did was that I wanted to run flutter apps without android studio, so I download android SDK and JDK 17, after I ran flutter doctor and it gave me that everything is good, I tried to run and it gave me this error:
FAILURE: Build failed with an exception.
* Where:
Build file 'E:\Flutter Apps\first_app\android\build.gradle'
* What went wrong:
Could not compile build file 'E:\Flutter Apps\first_app\android\build.gradle'.
> startup failed:
General error during semantic analysis: Unsupported class file major version 61
.............
So I tried an older version of JDK, it gave me another error, so I saw a third solution to run with JDK 17, which is to downgrade the gradle in gradle.properties, but it just gave me a fourth error, so does anyone know a final solution for this error ??
3 Answers
Based on the answer of DeveloperOmar 100 I found the following solution:
switch your Java version to a compatible version, in my case to Java version 16.0.2
To switch it you have to set your PATH. (e.g for Mac, you can use the
java_homecommand).check your Gradle version and update that one too, so it is compatible (see the Gradle wrapper docs) so in my case I had to change the
distributionUrlproperty inandroid/gradle/wrapper/gradle-wrapper.properties:distributionUrl=https\://
I ran into the same problem when I tried out Kotlin/Compose on my windows computer. I followed the instructions at
I struggled with this for a few hours before I finally was able to solve all the problems I encountered.
Solution
In gradle settings changed Gradle JVM: 11 (version 11.0.12)
In build.gradle.kts I deleted
tasks.withType { kotlinOptions.jvmTarget = "16" }