小编Sha*_*boy的帖子

Android Studio:无法加载类“com.google.common.base.Preconditions”,Gradle 同步失败

当我尝试在 Android Studio 3.1.2 上打开我的项目时,我收到此 Gradle 项目同步失败错误,并显示以下消息

无法加载类“com.google.common.base.Preconditions”。导致此意外错误的可能原因包括:

  • Gradle 的依赖项缓存可能已损坏(有时会在网络连接超时后发生。)重新下载依赖项并同步项目(需要网络)
  • Gradle 构建进程(守护进程)的状态可能已损坏。停止所有 Gradle 守护进程可能会解决此问题。停止 Gradle 构建进程(需要重新启动)
  • 您的项目可能正在使用第三方插件,该插件与项目中的其他插件或项目请求的 Gradle 版本不兼容。
如果 Gradle 进程损坏,您还可以尝试关闭 IDE,然后终止所有 Java 进程。

gradle-wrapper.properties 文件

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
Run Code Online (Sandbox Code Playgroud)

构建.gradle 文件

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()
    } …
Run Code Online (Sandbox Code Playgroud)

intellij-idea kotlin android-studio android-gradle-plugin

1
推荐指数
1
解决办法
7951
查看次数