What gradle -v
returns is absolutely irrelevant.
Usually you should not even have any Gradle version installed locally at all anyway.
Each project should have the 4 Gradle wrapper files included which defines and manages the Gradle version that is used.
The Gradle version is defined in gradle/wrapper/gradle-wrapper.properties
by default
The error from your last message is something different. You try to use targetCompatibility
which seems to not exist, probably because you do it on a project that does not apply any javaesque plugin. But it would anyway better to use JVM toolchains instead.