16

I'm having various Gradle problems after a new clean Eclipse install. They seem to be associated w/ this "Problem" message:

Could not run phased build action using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-7.1.1-bin.zip'.
Initialization script 'Z:\eclipse-workspace\.metadata\.plugins\org.eclipse.buildship.core\init.d\eclipsePlugin.gradle'
Could not compile initialization script 'Z:\eclipse-workspace\.metadata\.plugins\org.eclipse.buildship.core\init.d\eclipsePlugin.gradle'.
startup failed:
General error during semantic analysis: Unsupported class file major version 60
java.lang.IllegalArgumentException: Unsupported class file major version 60
    at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:196)
.....
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
    at java.base/java.lang.Thread.run(Thread.java:831)
1 error

I've already tried deleting .gradle & "Gradle->Refresh Gradle Project". I've also tried this: stackoverflow

My Java install is clean:

java version "16.0.1" 2021-04-20

& confirmed Eclipse is pointing to it ("Preferences->Java->Installed JREs").

Installation details:

Buildship: Eclipse Plug-ins for Gradle  3.1.5.v20210113-0929
Eclipse IDE for Java Developers 4.20.0.20210612-1200    

Windows 10.

Eclipse Install Err Log:

!ENTRY org.eclipse.buildship.core 2 2 2021-07-09 11:22:05.951
!MESSAGE Initialize project testgradleprj failed due to an error in the referenced Gradle build.
!STACK 0
org.gradle.tooling.BuildException: Could not execute build using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-7.1.1-bin.zip'.
JDOaktown
  • 4,262
  • 7
  • 37
  • 52

5 Answers5

8

Gradle 6.8 does not work with Java 16.
Java 16 supported starting with Gradle 7

"In previous Gradle versions, running Gradle itself on Java 16 resulted in an error."

https://docs.gradle.org/7.0/release-notes.html#java-16

LMC
  • 10,453
  • 2
  • 27
  • 52
7

Thanks to LMC. I changed the project prefs->Gradle from Wrapper to Specific=7.1.1 :

enter image description here

JDOaktown
  • 4,262
  • 7
  • 37
  • 52
  • 2
    You could also try [upgrading the wrapper](https://docs.gradle.org/current/userguide/gradle_wrapper.html). – LMC Jul 09 '21 at 23:19
  • Thanks. I saw this but couldn't figure out how to apply it against Eclipse. I right-clicked the "wrapper" task in the Gradle Tasks button but still not clear. – JDOaktown Jul 09 '21 at 23:29
  • 1
    OK. I did the following: Z:\eclipse-workspace\gradleprj4>.\gradlew wrapper --gradle-version 7.1.1 BUILD SUCCESSFUL in 1s 1 actionable task: 1 up-to-date – JDOaktown Jul 09 '21 at 23:37
  • 1
    Eclipse will respect the wrapper in the project I think. – LMC Jul 09 '21 at 23:37
0

I have updated my gradle-warpper.properties file with

distributionUrl=https://services.gradle.org/distributions/gradle-6.4.1-bin.zip from distributionUrl=https://services.gradle.org/distributions/gradle-5.6.2-bin.zip

and refresh the gradlew project in eclipse. It's build successfull Note : Java 11 version is installed in my machine

0

Change your gradle.properties file

distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip

And build.gradle file

 dependencies {
        classpath 'com.android.tools.build:gradle:7.0.0'
    }
Anand
  • 4,355
  • 2
  • 35
  • 45
0

In my case, it was because Eclipse was running upon a JVM that was different from the one used by my local Gradle.

I edited the eclipse.ini file so that Eclipse would run on the same JVM as my local Gradle (i.e. the one pointed by JAVA_HOME) and it worked!

Daniele Repici
  • 312
  • 3
  • 18