I was trying to build a project with the Ubuntu-packaged gradle v4.4.1-10, then after the following error popped up.
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine java version from '11.0.2'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
Thereafter, when when gradle to v7.4.2, the problem still persisted, but after deleting & re-recloning the same repository, it worked.
I’ve thought it was kind of cache problem, but no ./gradle/cache directories within the project’s directory.
I was curious to understand the root cause behind this! Is there some kind of metadata that gets saved somewhere at some file at the first invocation of gradle within the project’s directory?
Thanks!
Did you build from the command line or through an IDE?
IntelliJ for example has (or maybe had) a bug that even if you change the Gradle version, it used an old connection to the daemon which still was the old version and thus built with the old Gradle version.
Or the project in question defines an old Gradle version in its wrapper files and the IDE rightfully uses the wrapper-defined version.
Java 11 support was added in Gradle 5.0. (Compatibility Matrix)
Gradle 4.4.1 is pretty ancient, it was released 2017, you shouldn’t use it for creating new builds.
And you should practically never use any installed Gradle version to build an existing Gradle project.
Every Gradle project that does not contain the four wrapper files imho has a bug.
The wrapper files define the exact Gradle version to use for running the build and make sure it is used automatically, as the build was designed for that Gradle version and is know to behave as expected with that Gradle version.
Did you build from the command line or through an IDE?
I was building via the command line.
I think i’ve had a misconception, as i was bewildered by working on multiple projects
the build was designed for that Gradle version and is know to behave as expected with that Gradle version.
The library project that i’ve cloned back then neither built with its default settings nor specified which versions of either java or the respective gradle version at the readme, so i had to manually alter the version in order to build successfully