8
votes

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 
2
What Java version are you using? - Nicolas
I'm using the 13.0.2 - Noemi
Oh I missed that. LibGDX isn't compiled against java 13 so there might be some binary incompatibilities. Can you try with Java 11 or 8? - Nicolas
I've tried and it worked, thank you! - Noemi

2 Answers

13
votes

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.

0
votes

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]'