General error during semantic analysis: Unsupported class file major version 57

Viewed 77074

I'm trying to setup libgdx for a desktop game and when I try to generate the project I have this error and the build fails. I've the latest versions of Java(13.0.2) and Gradle(6.6), both set as environment variables in the path. Can somebody help me?

The error looks like this:

Could not compile settings file 'C:\Users\noemi\Desktop\Test\settings.gradle'.
> startup failed:
  General error during semantic analysis: Unsupported class file major version 57
  
  java.lang.IllegalArgumentException: Unsupported class file major version 57 
6 Answers

This is not a LibGDX issue. Gradle 5 is incompatible with Java 13. You either need to update Gradle (the wrapped version in your project) to Gradle 6 or later, or you need to use a lower version of the JRE.

To update the wrapped gradle, go to gradle/wrapper/gradle-wrapper-properties in your project and update the version number. I'm using 6.1.1.

distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip

If you have an older LibGDX project, you might have to modify the build.gradle file in the android module to be compatible with Gradle 6. You can copy-paste to replace the copyAndroidNatives task with the one here.

startup failed: General error during semantic analysis: Unsupported class file major version 61

how to fix this react native issues JAVA JDK 17

Go to the android/ directory of your react-native project

Create a file called local.properties with this line:

sdk.dir=C:\Android\sdk

GOTO android\gradle\wrapper\gradle-wrapper.properties

CHANGE

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

TO

distributionUrl=https://services.gradle.org/distributions/gradle-7.3-all.zip

GOTO

android\gradle.properties add this line

org.gradle.jvmargs=-Xmx1536M --add-exports=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED

This problem occurred when I run my old Flutter project that I coded 2 years ago. I think with Android project will also fix in the same way. I'm use MacOS and Android Studio Bumblebee.

First, need to move to the android folder and check gradle version:

cd android 
./gradlew --version

enter image description here

It show Gradle version 6.7.1 and you need attention to the JVM line, and my JDK version is 15.0.2. It is too new for this project. So you must to downgrading from open jdk version to old version or upgrade Gradle version in gradle/wrapper/gradle-wrapper.properties to new version.

If you downgrade JDK version, you can download from this. In my case, I downgraded from Java SE 15 to Java SE 11.

After I open Android of Flutter project

enter image description here

Go to Preferences->Build, Execution, Deployment → Build Tools → Gradle → and choose JDK version 11. enter image description here

Go to Build -> Clean Project -> Rebuild Project.

enter image description here

Go to Terminal run java --version, if it still show JE version 15 then You must set JAVA_HOME before.

You only need to add the following to your .bash_profile or .zshrc

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-11.0.15.jdk/Contents/Home

Save and go to android folder and run again

./gradlew --version

It will show JDK version 11 correct.

enter image description here

Finally, run flutter run.

If you're using eclipse, go to

Eclipse > Preferences > Gradle

Update Java home to point to Java home location

I have downgraded gradle file thats why this error happens so finally I have to change Gradle wrapper file From

distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip

to

distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
Related