我已经在Android Studio中导入了项目,但是遇到了这个错误:
- Caused by: java.lang.NoClassDefFoundError: org/gradle/internal/impldep/com/google/common/collect/Lists
- Caused by: java.lang.ClassNotFoundException: org.gradle.internal.impldep.com.google.common.collect.Lists
这是我的dependencies
:
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
}
}
我已经看到了这个问题找不到类: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' }
}
}
buildscript.dependencies
...或者可能是一些损坏的Gradle插件。这至少可以解释为什么这些方法从未产生过差异。 - Martin Zeitlerguava
插件并重建本地存储库。或者尝试“使缓存无效并重新启动”...甚至手动删除所有缓存目录。我几乎可以确定这与(取决于此损坏的依赖项来自何处)有关。我的意思是,我无法真正重现这个问题,而且很匆忙... - Martin Zeitler