gradle7.3.3 Could not determine java version from '11.0.10' - java

I am trying be build a java application using "gradlew build". I have installed gradle 7.3.3
and I have java 11.0.10.
From other answers I understand that gradle is compatible with older version but here I have java 11 and latest gradle still I am getting this error.
I also tried following gradle wrapper --gradle-version 7.3.3 but it is giving me following error:
Can anyone suggest what I am missing or should differently.
EDIT: (Content of gradle.wrapper.propertiese file)
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https://server_path/gradle/4.6/gradle-4.6-bin.zip
Thanks

After doing some research I found the resolution, posting so that it might help someone else.
NOTE: the gradle you installed on your machine and the gradle used by the project you are trying to build might be different. If you are in bad luck then they might be incompatible based on java version you have on your system.
I had gradle 7.3.3 on my system and the project was using gradle 4.6. The gradle used by project is not compatible with java 11. So, to be on safe side I downgraded both Gradle (to v 4.6) and java (to 1.8) and it worked.
You might not required to downgrade the gradle version on your local machine. I will try that as well and update this answer.
EDIT: It worked with Gradle 7.3.3, java 1.8 and the project using Gradle 4.6.

Related

Could not initialize class org.codehaus.groovy.runtime.InvokeHelper

Spring Boot Project
I'm using gradle 5.2.1 I can't change the version because I'm working on someone else's code. When I build the project in IntelliJ I get the following error:
* What went wrong:
Could not initialize class org.codehaus.groovy.runtime.InvokeHelper
I'm using IntelliJ terminal in my code folder with command ./gradlew clean build install.
when I check ./gradle -version it shows JVM: 16.0.2
I feel the problem is with my jdk version.
As per compatibility matrix , only gradle versions of 7 are supporting java 16.
May be you can use older version of jdk which is supporting your current gradle.

Issues with running a LibGDX project

I downloaded the libGDX setup jar file, I generated a project and imported it (to eclipse). Once I try to run the project eclipse outputs an error:
Description Resource Path Location Type
Could not create an instance of Tooling API implementation using the specified Gradle distribution 'https://services.gradle.org/distributions/gradle-4.6-bin.zip'.
Could not create service of type FileMetadataAccessor using NativeServices.createFileMetadataAccessor().
Could not determine java version from '11.0.2'.
I have no idea how to solve this problem.
The problem is that you are using Java 11. Try it with Java 8. The HTML module does not compile with a Java version greater then 8.
Gradle 4.6 likely does not support Java 11.
You can either upgrade to a newer version of Gradle or downgrade your JDK version.
I would recommend updating to Gradle 4.10.2 as it is the latest Gradle 4 variant (you can try Gradle 5 however it may introduce some breaking changes)
This can be done by running in the root of your project:
Linux / MacOS:
./gradlew wrapper --gradle-version=4.10.2
Windows:
gradle wrapper --gradle-version=4.10.2

Importing a Gradle project in IntelliJ using different java jdk version

I tried to import a gradle project in IntelliJ and I'm getting the following error :
Error:Could not determine java version from '9.0.4'.
As said is the gradle project in java 1.8 ( exactly 1.8.0_152) and the version on my Linux is 9.0.4.
I think I should downgrade the version from 9.0.4 to this 1.8.0_152 but I don't know how to do it.
Can I fix the problem without downgrading the Java version ?
This is a well known bug! Here you can find the issue documentation with a possible solution on github: #16536
Edit the file /android/gradle/wrapper/gradle-wrapper.properties and update the last line with:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-rc-2-all.zip
Alternate I found this intellij specific solution, solved by pointing intellij at a location of a custom gradle install:
"File > Settings... > Build, Execution, Deployment > Gradle > Use local gradle distribution"

Error:BUG! exception in phase 'class generation' in source unit '_BuildScript_' unsupported Target MODULE

I'm trying to create a new Java 9 project using gradle but right after project creation I received error from gradle:
Error:BUG! exception in phase 'class generation' in source unit '_BuildScript_' unsupported Target MODULE
Java version: 9 (build 9+178)
Gradle version: 4.1-rc-2
According to this article those java/gradle versions should be compatible.
How can I solve this problem?
Any help highly appreciated.
I have solved it by downgrading Gradle JVM to 8.
It is not perfect but keeps you going while jdk9 and gradle and intellij stabilises.
Intellij View
Setting the Gradle home to local Gradle distribution solved the issue in my case.
Java version: 9+181
Gradle version: 4.1
Intellij version: 2017.2.2
if we set to use default Gradle wrapper, IntelliJ downloads an earlier version of Gradle. I think it is the reason for failure.
Seems fixed in 2017.3
See IntelliJ IDEA 2017.3 173.2941.3 Release Notes: https://confluence.jetbrains.com/display/IDEADEV/IntelliJ+IDEA+2017.3+173.2941.3+Release+Notes
See issue: https://youtrack.jetbrains.com/issue/IDEA-171520
This issue seems to have been fixed in Groovy 2.4.12 and upgrading to at least that version resolved a similar problem in https://github.com/jenkinsci/JenkinsPipelineUnit/issues/292.

IntelliJ Gradle Could not Determine Java Version

I'm using IntelliJ to work with a Gradle project. I noticed that whenever I try to refresh the Gradle project (or when trying to import/re-import a project as a Gradle project) I get the following error:
Error: Could not determine the Java version
$JAVA_HOME is set, the SDK is set to Java 8 (and gradle -version confirms it is also is set to Java 8), and the project builds fine from the command line. Restarting IntelliJ also does nothing. I also deleted the project specific and global .gradle folders, which did not resolve the issue.
I am running IntelliJ 14.1.4 on Ubuntu 15.04 and Gradle 2.5.
EDIT: Tried it on a different machine (also Ubuntu 15.04, Oracle Java 8) running IntelliJ 14.1.1 and it worked correctly.
I had this problem too. It seems it was linked to the project being setup with a rather old gradle build. Changing distributionUrl to a new distribution in /gradle//wrapper/gradle-wrapper.properties solved it
You should try to switch Idea boot jdk. It works for me.

Categories

Resources