I used Mac Machine and IntelliJ Idea. I found this Compatibility Matrix of Gradel
and Java
.
https://docs.gradle.org/current/userguide/compatibility.html
I try to import this project https://github.com/udacity/ud282 from Github and when I try to run build.Gradle it shows me error Message:
JDK 18.0.1 isn't compatible with Gradle 4.4.1. Please fix JAVA_HOME environment variable.
when I ask the shell
to show me JAVA_HOME
using echo $JAVA_HOME
command it shows the path
/Users/lama/Library/Java/JavaVirtualMachines/openjdk-18.0.1.1/Contents/Home
And another error Message:
Unsupported Java.
Your build is currently configured to use Java 16.0.2. It's recommended to use Gradle 7.0 or newer.
Possible solution:
- Use Java 1.8 as Gradle JVM: Open Gradle settings
- Open Gradle wrapper settings, change `distributionUrl` property to use compatible Gradle version and reload the project
When I ask the shell
about the Gradle
version gradle -v
it shows:
------------------------------------------------------------
Gradle 7.4.2
------------------------------------------------------------
Build time: 2022-03-31 15:25:29 UTC
Revision: 540473b8118064efcc264694cbcaa4b677f61041
Kotlin: 1.5.31
Groovy: 3.0.9
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 18.0.1.1 (Oracle Corporation 18.0.1.1 2-6)
OS: Mac OS X 11.6 x86_64
CodePudding user response:
The compatibility matrix you mentioned (https://docs.gradle.org/current/userguide/compatibility.html) specifically says no version of Gradle (currently at version 7.4.2) is compatible with Java 18 yet.
Your best bet is to try installing/switching to an older version of Java (like 8 perhaps) and running the ./gradlew
wrapper as @Joachim Sauer suggested. That should automatically download and install Gradle 4.4.1.