libGDX Unsupported Class File Major Version

16th February 2023, 19:00:00


Unsupported Class File Major Version happens whenever you’re using a JDK which isn’t compatible with the gradle version used in the project.


This can be easily solved by commonly downgrading to a different version. For libGDX specifically 17 is a good choice. (Or for older projects 8).

If you don’t have a good one installed, I’d recommend to install Bellsofts JDK. The installer has good defaults, and even supports Oracle Specific tools like VisualVM.

Compatibility Matrix

Open gradle/wrapper/ in your project to figure out the gradle version (Check the distributionUrl). You can check the compatible JDK version on gradles website.


There are two steps to fix that in Intellij:

1. Settings

Open File -> Settings, then extend Build, Execution, Deployment -> Build Tools and click on Gradle. Change the Gradle JVM to Project SDK.

Screenshot of settings

2. Project Structure

Open File -> Project structure, then change the SDK to 11 (or 8). If you don’t want to install a JDK system wide, you can download one in the same drop down.

Screenshot of project structure

3. Rebuild the project

Open the Gradle tab on the right of IntelliJ then click on the Reload All Gradle Projects button.

Screenshot of gradle tab

After that step the project should work and IntelliJ should setup all the dependencies.

Android Studio

1. Change Gradle Settings

Open the Gradle tab on the right of Android Studio, then click on the Settings button and click on Gradle Settings.

Screenshot of gradle tab

In the newly opened dialog, change the Gradle JDK to 11 (or 8).

Screenshot of settings

2. Rebuild the project

Click on the Elephant with blue arrow icon to resync the project.

Screenshot of sync button

After that step the project should work and Android Studio should setup all the dependencies.


Import Dialog

I’m not really familiar with eclipse, but it looks like it doesn’t even allow you to import the gradle project when the project throws that error.

So make sure to change Java home to an appropiate version:

Screenshot of import options

Settings Dialog

If you however managed to open the project somehow, you can change the JDK version under Project -> Properties. Then in the dialog select the Gradle tab and change Java home there.

Screenshot of settings dialog

After that resync the project by right clicking on the project in the Package Explorer -> Gradle -> Refresh Gradle Project.

Screenshot of context menu