34

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 
Noemi
  • 341
  • 1
  • 3
  • 3

7 Answers7

29

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.

Tenfour04
  • 83,111
  • 11
  • 94
  • 154
25

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
Ejeh
  • 425
  • 5
  • 7
  • 1
    Unable to start the daemon process. This problem might be caused by incorrect configuration of the daemon. For example, an unrecognized jvm option is used. – Ejeh Nov 19 '21 at 01:18
  • 1
    react native Unrecognized option: - Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. – Ejeh Nov 19 '21 at 01:19
  • 1
    Unrecognized option: - Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. – Ejeh Nov 19 '21 at 01:19
  • This worked! using java 17.0.2 2022-01-18 LTS on Mac OS – Marc Pope Feb 10 '22 at 19:59
  • Update gradle version to 7.3 helped me – David Mar 21 '23 at 04:42
  • which os are you using? – Ejeh Mar 23 '23 at 08:53
12

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.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Doan Bui
  • 3,572
  • 25
  • 36
3

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
Sushant Gosavi
  • 3,647
  • 3
  • 35
  • 55
2

If you're using eclipse, go to

Eclipse > Preferences > Gradle

Update Java home to point to Java home location

KhogaEslam
  • 2,528
  • 1
  • 20
  • 21
0

Check gradle version and bundle version using the following link Link https://developer.android.com/studio/releases/gradle-plugin#updating-gradle

If you want to upgrade android/gradle/build.gradle change dependencies classpath 'com.android.tools.build:gradle:[latest version]'

Jenish MS
  • 357
  • 2
  • 13
0

Java(13.0.2) and Gradle(6.6) are not compatible.

Fix

You can either :

  • change your JDK version to 14. Path to environment variable JAVA_HOME
  • or keep your JDK to 13.x and change your Gradle version to 6.0 . In your project gradle/wrapper/gradle-wrapper.properties , change the line to distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-bin.zip . Available Gradle distributions

How to know the compatible versions ?

Table Java Compatibility

Check this https://docs.gradle.org/current/userguide/compatibility.html

Java version First Gradle version to support it
8 2.0
9 4.3
10 4.7
11 5.0
12 5.4
13 6.0
14 6.3
15 6.7
16 7.0
17 7.3
18 7.5
19 7.6
20 8.1 ⚠
Raymond Chenon
  • 11,482
  • 15
  • 77
  • 110