Marcel Rosier
Marcel Rosier

Reputation: 73

Android Studio: Gradle sync failed: Unable to load class

Since i've reinstalled Android Studio i have a strange problem everytime i create a project. Immediately after creating it, i get the Exception : Gradle sync failed: Unable to load class 'org.gradle.internal.typeconversion.NotationConverter'. and therefore i cant do anything at all in android studio at the moment.

I already tried all of the follwoing suggestions and i also cleaned and rebuild the project although that shouldnt be the problem because the problem also appears whenever im creating a new project.

Error:Unable to load class 'org.gradle.internal.typeconversion.NotationConverter'. Possible causes for this unexpected error include:

  • 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.

Any ideas?

Upvotes: 7

Views: 10978

Answers (1)

David Pisoni
David Pisoni

Reputation: 3437

Someone on my team just ran in to this today. Somehow, their install of gradle became corrupted. Solution was to remove it – the gradle wrapper downloaded a replacement as soon as we invoked it again. So:

  1. Find the version/package of gradle your project is using: look in gradle/wrapper/gradle-wrapper.properties and observe the gradle version (e.g., distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip is gradle-6.5-bin.)
  2. Remove the corresponding gradle package from your gradle cache: e.g., rm -r ~/.gradle/wrapper/dists/gradle-6.5-bin
  3. Invoke the gradle wrapper again (on command line or from AS, doesn't matter), and it will download a new package to replace the one you removed: (e.g., ./gradlew assembleDebug)

After that, we were "back in business!"

Upvotes: 10

Related Questions