Gradle: Could not determine java version from '11.0.2'
There are two different Gradle applications in your system.
the system-wide Gradle
This application is invoked bygradle (arguments)
.the gradle-wrapper
The gradle-wrapper is specific to every project and can only be invoked inside the project's directory, using the command./gradlew (arguments)
.
Your system-wide gradle version is 5.1.1 (as the OP explained in the comments, running the command gradle --version
returned version 5.1.1).
However, the failure is the result of a call to the gradle-wrapper (./gradlew
). Could you check your project's gradle wrapper version? To do that, execute ./gradlew --version
inside your project's folder, in the directory where the gradlew and gradlew.bat files are.
Update 1:
As running ./gradlew --version
failed, you can manually check your wrapper's version by opening the file:
(project's root folder)/gradle/wrapper/gradle-wrapper.properties
with a simple text editor. The "distributionUrl" inside should tell us what the wrapper's version is.
Update 2:
As per the OP's updated question, the gradle-wrapper's version is 4.1RC1.
Gradle added support for JDK 11 in Gradle 5.0. Hence since 4.1RC does not support running on JDK 11 this is definitely a problem.
The obvious way, would be to update your project's gradle-wrapper to version 5.0.
However, before updating, try running gradle app:installDebug
. This will use your system-wide installed Gradle whose version is 5.1.1 and supports running on Java 11. If this works, then your buildscript (file build.gradle) is not affected by any breaking changes between v.4.1RC1 and v.5.1.1 and you can then update your wrapper by executing from the command line inside your project's folder: gradle wrapper --gradle-version=5.1.1
[*].
If gradle app:installDebug
fails to execute correctly, then maybe you need to upgrade your Gradle buildscript. For updating from v.4.1RC1 to 5.1.1, the Gradle project provides a guide (1, 2) with breaking changes and deprecated features between minor releases, so that you can update gradually to the latest version.
Alternatively, if for some reason you can't or don't want to upgrade your Gradle buildscript, you can always choose to downgrade your Java version to one that Gradle 4.1RC1 supports running on.
[*] As correctly pointed out in the answer by @lupchiazoem, use gradle wrapper --gradle-version=5.1.1
(and not ./gradlew
as I had originally posted there by mistake). The reason is Gradle runs on Java. You can update your gradle-wrapper using any working Gradle distribution, either your system-wide installed Gradle or the gradle-wrapper itself. However, in this case your wrapper is not compatible with your installed Java version, so you do have to use the system-wide Gradle (aka gradle
and not ./gradlew
).
IntelliJ/Gradle Could not determine java version from '11.0.1'
If you use IntelliJ
Checks:
Navigate to:
File >> Settings >> Build, Execution, Deployment >> Build Tools >> Gradle
.Alongside
Gradle JVM:
make sure you select the correct version of Java.Navigate to:
Right-Click 'Project Root Directory' & SelectOpen Module Settings
.Project Structure
windows shows-up. Make sure your JDK home path is added to thePlatform Settings >> SDKs : JDK home path
Still, on the same window
Project Structure
, select correct SDK relevant to your project underProject Settings >> Modules : Module SDK
Fix/Solution:
Nvavigate to & open:gradle/wrapper/gradle-wrapper.properties
& update the distributionUrl version to the latest version.
In my case (at the time of this post), my older version was:distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip
And my latest version is:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-bin.zip
As shown below:
In your build.gradle file make sure you set:
sourceCompatibility = 11
ERROR: Could not determine java version from 17.0.1
From official gradle doc:
A Java version between 8 and 16 is required to execute Gradle. Java 17 and later versions are not yet supported.
You need to downgrade you java to work with gradle .
UPDATED:
As gradle version 7.3 released at 5th Nov 2021 , It will now provide support to Java 17.
So you either upgrade to 7.3 gradle version or downgrade your java version .
Could not determine java version from '11.0.1' when try to run gradle command
Upgrade to Gradle 4.7.
The Release Notes says:
Fixed issues
46 issues have been fixed in Gradle 4.7.
- ...
- [#4515] - Support Java 11 Version Name
- ...
Related Topics
"Int Cannot Be Dereferenced" in Java
Graphics Rendering in Title Bar
What Does It Mean: the Serializable Class Does Not Declare a Static Final Serialversionuid Field
How to Make a Java Class That Implements One Interface with Two Generic Types
Retrieving a Random Item from Arraylist
How to Convert String to Date Without Knowing the Format
Pdfbox 2.0.2 > Calling of Pagedrawer.Processpage Method Caught Exceptions
Difference of Maven Jaxb Plugins
How to Find the Jvm Version from a Program
How to Make Notepad to Save Text in Utf-8 Without the Bom
How to Get a Defaulttablemodel Object's Data into a Subclass of Defaulttablemodel
Spring MVC - How to Return Simple String as JSON in Rest Controller
Java Linkedhashmap Get First or Last Entry
How to Format a String in an Email So Outlook Will Print the Line Breaks
How to Force Browser to Download File