首页 > 解决方案 > 无法加载类“org.gradle.internal.impldep.com.google.common.collect.Lists”

问题描述

我在我的 android studio 中导入了项目,我遇到了这个错误,

这是我的依赖

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    //noinspection GradleDynamicVersion
    implementation 'com.facebook.react:react-native:0.20.1'  // From node_modules

implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'

implementation("com.google.guava:guava:30.1-jre")

debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
  exclude group:'com.facebook.fbjni'
}

debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
    exclude group:'com.facebook.flipper'
}

debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
    exclude group:'com.facebook.flipper'
}

if (enableHermes) {
    def hermesPath = "../../node_modules/hermes-engine/android/";
    debugImplementation files(hermesPath + "hermes-debug.aar")
    releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
    implementation jscFlavor
}

}

在此处输入图像描述

我已经看到了这个问题No Class Found: com.google.common.collect.Lists但是当我尝试添加https://github.com/google/guava时错误仍然存​​在

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:3.5.2")
        compile "com.google.guava:guava:16+"
        compile  "junit:junit:4.10"
    }
}

allprojects {
    repositories {

        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }

        google()
        jcenter()
        maven { url 'https://www.jitpack.io' }
    }
}

标签: javaandroidgradle

解决方案


对我来说同样的问题。Android Studio 彻底搞砸了。无效/重新安装/新项目。还是被坑了。已删除 .gradle 目录 (Linux)。那解决了它。不知道起始事件。提交了一个错误。


推荐阅读