How to Solve 'unable to load class 'org.gradle.initialization.BuildCancellationToken'

When i have been opening my project, after sync my gradle suddenly there is error like this


Error:Unable to load class 'org.gradle.initialization.BuildCancellationToken'. Possible causes for this unexpected error include:

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.


Ho to solve that?? please, i need help quickly for my android task

Upvotes: 6

Views: 25883

Answers (3)

Unable to load class 'org.gradle.initialization.BuildCompletionListener' org.gradle.initialization.BuildCompletionListener

Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)

Re-download dependencies and sync project (requires network) The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.

Stop Gradle build processes (requires restart) Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

Upvotes: -3

Steve White
Steve White

Reputation: 450

This is a case of a misleading error message -- they're jumping to a conclusion that is not the usual case. It wasted a lot of people's time.

It will often show up when the synch step has run into a situation in the build dependencies that it can't handle. I have run into it especially when building old projects that haven't been opened in a while.

My solution has been to back up the build.gradle files (or their Kotlin equivalents), and strip them down, commenting out all dependencies, until the synch can finish.

Then, carefully, replace dependencies, based what the build step finds missing.

(I'm not sure if deleting the build and .gradle directory and the whole "invalidate caches" process is necessary -- maybe doesn't hurt, but it's very time-consuming.)

Upvotes: 3

Edmond T Zinzombe
Edmond T Zinzombe

Reputation: 59

The gradle is corrupt,delete your gradle. On Intellj go to Settings; Build, Execution, Deployment then Gradle and change to a local gradle distribution and download the dependencies.

Upvotes: 3

Related Questions