Unsupported class file major version 66 | Java version 22 | Gradle 7.6.4

This was asked a lot of times, but in this case JAVA version is correct, but issue persists…

java -version
java version "22.0.1" 2024-04-16
ionic start myApp blank --cordova
cd myApp
ionic cordova run android
...
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details

FAILURE: Build failed with an exception.

* What went wrong:
Could not open settings generic class cache for settings file 'D:\myApp\platforms\android\settings.gradle' (C:\Users\dange\.gradle\caches\7.6.4\scripts\agivqgfsfjqplymmxyc25ho9b).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 66

Any ideas?

According to this, Gradle doesn’t yet support Java 22.

Okay, what versions of java/gradle i should install to make it work?

Downgraded OpenJDK to 21, upgraded Gradle to 8.7. Started… it downloaded Gradle 7.6.4 and returned error: Unsupported class file major version 65…

I’ve downgraded OpenJDK to 20 and not it says Unsupported class file major version 64 WTF???

Android Studio comes with Java bundled with it so you shouldn’t have to mess with installing it yourself. Have you tried opening your project in Android Studio and building it directly there? It might recommend a fix or give a more detailed error.

I am not familiar with how the build/run command works for Cordova, but with Capacitor it uses the underlying build commands that come with Android Studio (99.9% sure).

From android studio i’ve imported this project and now i have error:

Caused by: java.lang.RuntimeException: No installed build tools found. Please install the Android build tools version 33.0.2.

I have tools v35


There’s no v 33 in list…

Try clicking the “Show Package Details” checkbox.