Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.Preconditions'. 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.

gradle-wrapper.properties file

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

build.gradle file

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

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
apply plugin: 'kotlin'

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
repositories {
    mavenCentral()
}
dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}
compileKotlin {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}
compileTestKotlin {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}
like image 508
Shayeeboy Avatar asked Dec 21 '25 17:12

Shayeeboy


1 Answers

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

like image 133
Shayeeboy Avatar answered Dec 23 '25 09:12

Shayeeboy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!