Skip to content Skip to sidebar Skip to footer

Android Studio: Unable To Load Class 'com.google.common.base.preconditions', Gradle Sync Failed

When i try opening my projects on Android Studio 3.1.2, I get this Gradle Project Sync failed error with the message below Unable to load class 'com.google.common.base.Preconditio

Solution 1:

The problem has been solved.

I deleted the .gradle folder in my home user directory which made Android Studio re-download all the files for the current version of gradle. It took quite a while to download and sync the first time but it has solved the problem.

Thank you very much for your assistance @Luis Henriques

Solution 2:

Clean and rebuild your project;

Check if you are working on offline mode:

File > Settings > Search for "offline" > uncheck "offline work"

After unchecking offline work, clean and rebuild again.

If it doesn't work, my guess is exactly what it says:

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.

Let me know if it worked.


UPDATE:

Why do you have:

repositories {
    mavenCentral()
}
...
dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}

Instead of:

buildscript {
    ext.kotlin_version = '1.2.41'
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
        ...

Also use "implementation" instead of "compile". So:

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

And why did you set these up in your project.gradle instead of in your app.gradle?

I think your gradle file is poorly structured. Hence the problem. Why don't you see how the default gradle files are set up and compare them with yours?

Hope this helps.

Solution 3:

Your local gradle distribution my be corrupt. Delete it and redownload it.

Post a Comment for "Android Studio: Unable To Load Class 'com.google.common.base.preconditions', Gradle Sync Failed"