Gradle: Could Not Determine Java Version from '11.0.2'

Gradle: Could not determine java version from '11.0.2'

There are two different Gradle applications in your system.

  1. the system-wide Gradle

    This application is invoked by gradle (arguments).

  2. 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:

  1. Navigate to:

    File >> Settings >> Build, Execution, Deployment >> Build Tools >> Gradle.

    Alongside Gradle JVM:
    make sure you select the correct version of Java.
    Gradle JVM

  2. Navigate to:
    Right-Click 'Project Root Directory' & Select Open Module Settings. Project Structure windows shows-up. Make sure your JDK home path is added to the Platform Settings >> SDKs : JDK home path
    Project Structure >> Platform Settings >> SDKs : JDK home path

  3. Still, on the same window Project Structure, select correct SDK relevant to your project under

    Project Settings >> Modules : Module SDK
    Module SDK

  4. 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:

    distributionUrl Version Update

  5. 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



Leave a reply



Submit