Android 在模块guava-20.0.jar(com.google.guava:guava:20.0)中找到重复类com.google.common.util.concurrent.ListenableFuture
当我在我的Android 在模块guava-20.0.jar(com.google.guava:guava:20.0)中找到重复类com.google.common.util.concurrent.ListenableFuture,android,firebase,guava,firebase-in-app-messaging,Android,Firebase,Guava,Firebase In App Messaging,当我在我的app/build.gradle中使用implementation'com.google.firebase:firebase inappmessaging display:17.2.0'时,我收到以下错误: 在模块guava-20.0.jar(com.google.guava:guava:20.0)和ListenableFuture-1.0.jar(com.google.guava:ListenableFuture:1.0)中找到重复类com.google.common.util.co
app/build.gradle
中使用implementation'com.google.firebase:firebase inappmessaging display:17.2.0'
时,我收到以下错误:
在模块guava-20.0.jar(com.google.guava:guava:20.0)和ListenableFuture-1.0.jar(com.google.guava:ListenableFuture:1.0)中找到重复类com.google.common.util.concurrent.ListenableFuture
转到文档以了解如何修复依赖项解析错误。
我的应用程序/build.gradle中也包含以下内容:
implementation 'com.google.android.gms:play-services-base:16.1.0'
implementation 'com.google.android.gms:play-services-analytics:16.0.8'
implementation 'com.google.android.gms:play-services-awareness:16.0.0'
implementation 'com.google.android.gms:play-services-cast:16.2.0'
implementation 'com.google.android.gms:play-services-gcm:16.1.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.android.gms:play-services-maps:16.1.0'
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.google.firebase:firebase-iid:17.1.2'
implementation 'com.google.firebase:firebase-messaging:17.6.0'
implementation 'android.arch.work:work-runtime:1.0.1'
implementation 'com.android.support:multidex:1.0.3'
apply plugin: 'com.google.gms.google-services'
也许我正在使用的某个库已经包含了对应用内消息传递依赖项的支持,然后它就变得多余了?谢谢。我在找到了解决方案。用户2297550说:
我只是在我的应用程序gradle文件的末尾添加了实现'com.google.guava:guava:27.0.1-android'
,错误消失了
这就是我的解决办法。现在我有了这个,我的应用程序可以正确编译:
implementation 'com.google.firebase:firebase-inappmessaging-display:17.2.0'
implementation 'com.google.guava:guava:27.0.1-android'
减少项目中重复的依赖关系
例如,许多依赖项使用support-v4和appcompat-v7作为包含的包,然后可能是不同的版本,因此您需要从依赖项内部删除这些包,并创建一个编译依赖项
这将删除库中包含的所有模块
android {
configurations {
all*.exclude module: 'appcompat-v7'
all*.exclude module: 'support-v4'
}
}
或者,您可以管理将每个依赖项抛出到更清晰的位置,删除包,如下所示:
dependencies {
implementation ('com.mapbox.mapboxsdk:mapbox-android-sdk:4.2.0@aar') {//depend on your library
transitive = true
exclude group: 'com.android.support', module: 'appcompat-v7'
exclude group: 'com.android.support', module: 'recyclerview-v7'
exclude group: 'com.android.support', module: 'design'
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.squareup.retrofit2' module: 'retrofit'
exclude group: 'com.squareup.retrofit2', module: 'retrofit'
exclude group: 'com.google.code.gson', module: 'gson'
exclude module: 'guava'//add this line if you have build error "found in modules guava-xxx-android.jar"
}
}
所有删除的依赖项必须在mapbox之外的一个副本中声明,以供所有使用它们的库使用。在build.gradle中添加此行
implementation 'com.google.guava:guava:27.0.1-android'
2020解决方案
谷歌知道这个错误,所以他们制作了一个特殊的软件包来修复冲突
将此添加到您的build.gradle
implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
我遇到了同样的问题。我在下面加了一行
implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
这是可行的,但我遇到了另一个问题-无法在单个dex文件中容纳请求的类(#methods:89411>65536)
要解决此错误,请确保按如下所示启用多索引
defaultConfig {
applicationId "com.techweezy.smartsync"
minSdkVersion 19
targetSdkVersion 29
versionCode 5
versionName "1.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true //added this line
}
然后最后添加以下行
implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
implementation 'androidx.multidex:multidex:2.0.1'
打开build.gradle
文件
不要更换!只需将这一行添加到依赖项{}
:
implementation 'com.google.guava:guava:<version>-jre'
implementation'com.google.guava:guava:-jre'
注意:要获取版本,请转到并查找最新版本的jre
我在构建我的Flutter项目时遇到了这个问题。不太清楚它为什么抬起它丑陋的头,但我在这里
所以,如果有人遇到这种情况,@Ray Li的回答对我很有用。您要编辑的build.gradle
文件是android/app
文件夹中的文件(即不是android
文件夹中的文件)
只需将实现'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
添加到文件末尾的依赖项部分,如下所示:
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
}
将此添加到您的gradle文件中
configurations {
all*.exclude group: 'com.google.guava', module: 'listenablefuture'
}
将这两个实现添加到应用程序级别build.gradle/app/build.gradle
implementation 'com.google.firebase:firebase-inappmessaging-display:17.2.0'
implementation 'com.google.guava:guava:27.0.1-android'
但是,这意味着什么?我们正在添加一些新的依赖项,而不是删除一些重复发生和错误消失的东西@JaiminModi说,“Guava是Google提供的一组核心Java库,包括新的集合类型(如multimap和multiset),不可变集合,一个图形库,以及用于并发、I/O、哈希、缓存、原语、字符串等的实用程序!它广泛用于谷歌的大多数Java项目,也被许多其他公司广泛使用。”目前最新的版本是implementation'com.google.guava:guava:28.2-android'
还有一个更新的版本:implementation'com.google.guava:guava:29.0-jre'
version27.0.1
在获得“无法访问类'com.google.common.util.concurrent.ListenableFuture.”后为我工作由于任何原因,io.ktor:ktor auth:1.5.2出现错误。第一个示例从库中删除所有包含的模块。如果您想从perticular library中删除一些导致错误的模块,那么请尝试perticular library.LOL的第二个示例,它应该永远留在项目中,还是?我们怎么知道什么时候可以删除它呢?谷歌的令人印象深刻的库这会很好,但是,如果你没有在你的grade defaultConfig上启用mutliDex,你会遇到另一个错误“无法在单个dex文件中容纳请求的类(#方法:89411>65536)”要解决此问题,请确保在依赖项上添加实现“androidx.multidex:multidex:2.0.1”,并在android DefaultConfig上设置multiDexEnabled true,然后将快速修复推送到ProductionSue tracker链接?这是确定何时可以删除依赖项的唯一方法。今天我的Flutter项目也突然发生了这种情况,发生在我升级包和Flutter版本之后。真的,伙计!像这样完全出乎意料的错误破坏了整个颤振开发体验。