Cordova buil error

Hi all, I know this has been asked before, but I am not able to solve it.

cordova build gives me:

Checking Java JDK and Android SDK versions

ANDROID_HOME=/Users/domenicogagliano/Library/Android/sdk (recommended setting)

ANDROID_SDK_ROOT=undefined (DEPRECATED)

Using Android SDK: /Users/domenicogagliano/Library/Android/sdk

Subproject Path: CordovaLib

Subproject Path: app

FAILURE: Build failed with an exception.

* What went wrong:

Could not open settings generic class cache for settings file '/Users/domenicogagliano/cordova_test/hello/platforms/android/settings.gradle' (/Users/domenicogagliano/.gradle/caches/7.6/scripts/dqjrgsw17c62wbpoagod92e1e).

> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 65

* Try:

> Run with **--stacktrace** option to get the stack trace.

> Run with **--info** or **--debug** option to get more log output.

> Run with **--scan** to get full insights.

* Get more help at **https://help.gradle.org**

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.6/userguide/command_line_interface.html#sec:command_line_warnings

**BUILD FAILED** in 501ms

Command failed with exit code 1: /Users/domenicogagliano/cordova_test/hello/platforms/android/gradlew -b /Users/domenicogagliano/cordova_test/hello/platforms/android/build.gradle cdvBuildDebug

Initially I had Java 22 and I dowgraded to Java 21 but the proble still persist. I am using Gradle 8.7 and I am using Mac Terminal

You are not using Gradle 8.7, but Gradle 7.6 and that is not compatible with Java 21:

image

Hi,
thanks for you reply.
the output of gradle --version is

------------------------------------------------------------
Gradle 8.7
------------------------------------------------------------

Build time:   2024-03-22 15:52:46 UTC
Revision:     650af14d7653aa949fce5e886e685efc9cf97c10

Kotlin:       1.9.22
Groovy:       3.0.17
Ant:          Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM:          21.0.3 (Oracle Corporation 21.0.3+7-LTS-152)
OS:           Mac OS X 14.4.1 x86_64

So how I am using 7.6? Is there a setting I need to change?

This is also the content of ~/.gradle/caches

drwx------   12 domenicogagliano  staff   384 26 Apr 08:49 .
drwxr-xr-x   13 domenicogagliano  staff   416 25 Apr 14:26 ..
drwxr-xr-x   10 domenicogagliano  staff   320 26 Apr 08:49 7.6
drwxr-xr-x    9 domenicogagliano  staff   288 25 Apr 16:53 8.7
-rw-r--r--@   1 domenicogagliano  staff   181 25 Apr 14:24 CACHEDIR.TAG
drwxr-xr-x  198 domenicogagliano  staff  6336 25 Apr 17:28 jars-9
drwxr-xr-x    5 domenicogagliano  staff   160  2 May  2023 journal-1
drwxr-xr-x    8 domenicogagliano  staff   256 25 Apr 14:25 modules-2
drwxr-xr-x  108 domenicogagliano  staff  3456 25 Apr 16:56 transforms-3
drwxr-xr-x    2 domenicogagliano  staff    64 25 Apr 16:53 transforms-4
-rw-------    1 domenicogagliano  staff    28  2 May  2023 user-id.txt
-rw-r--r--    1 domenicogagliano  staff    17  2 May  2023 user-id.txt.lock

I tried to delete the directory 7.6 but once I give cordova build it comes back.

Which Gradle version you have installed is irrelevant.
Usually, you do not even have any version of Gradle installed.
Any sane Gradle project includes the 4 Gradle wrapper files that control and manage the Gradle version that is used to execute the build if the wrapper is used and you should always use the wrapper.