January 06, 2021

Published January 06, 2021 by

Gradle build failed in eclipse : Could not create an instance of type eclipsePlugin

I upgraded my Eclipse IDE to version 2020-12 (4.18.0) and started to get Gradle build error after launching the IDE.

In Eclipse console it showed this error:


FAILURE: Build failed with an exception.

* What went wrong:

Could not create an instance of type eclipsePlugin_5gol6cepvkmdl1guwpr4mu03j.

> Could not initialize class org.codehaus.groovy.runtime.InvokerHelper

* Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.


In Eclipse Problems tab it showed: 

Could not run build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-5.2.1-bin.zip'.

Could not create an instance of type eclipsePlugin_5gol6cepvkmdl1guwpr4mu03j.

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


Solution:

The solution of the problem is simply upgrading Gradle. Previous gradle version was 5.2.1, then I upgraded to version 6.7.1 and got it resolved.

For gradlew wrapper, file gradle-wrapper.properties needs to be modified to update distributionUrl. This file is located at Project Root | gradle | wrapper.

distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip.

After the update, gradlew clean build command will download the new gradle version and the problem will be resolved.