Jai*_*oya 3 android guava firebase firebase-in-app-messaging
在我的中使用implementation 'com.google.firebase:firebase-inappmessaging-display:17.2.0'时app/build.gradle,出现以下错误:
Duplicate class com.google.common.util.concurrent.ListenableFuture found in modules guava-20.0.jar (com.google.guava:guava:20.0) and listenablefuture-1.0.jar (com.google.guava:listenablefuture:1.0)
Go to the documentation to learn how to Fix dependency resolution errors.
Run Code Online (Sandbox Code Playgroud)
我的内在app/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'
Run Code Online (Sandbox Code Playgroud)
也许我正在使用的库之一已经包含对In-App Messaging依赖的支持,然后它变得多余了?谢谢。
Ray*_* Li 280
2020解决方案
谷歌知道这个错误,所以他们制作了一个特殊的包来解决这个冲突。
将此添加到您的 build.gradle
implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
Run Code Online (Sandbox Code Playgroud)
Tar*_*eem 19
我刚刚在构建 Flutter 项目时遇到了这个问题。不太确定为什么它抬起丑陋的头,但我在这里。
因此,如果任何 Flutter 开发人员遇到此问题,@Ray Li 的回答对我有用。将build.gradle要编辑的文件是一个在android/app文件夹中(不是一个即中android的文件夹)。
只需implementation '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'
}
Run Code Online (Sandbox Code Playgroud)
Dhr*_*arg 18
将其添加到您的 gradle 文件中
configurations {
all*.exclude group: 'com.google.guava', module: 'listenablefuture'
}
Run Code Online (Sandbox Code Playgroud)
小智 12
在 build.gradle 添加这一行
implementation 'com.google.guava:guava:27.0.1-android'
Run Code Online (Sandbox Code Playgroud)
我添加了这个并且非常适合我。
implementation 'com.google.guava:guava:27.0.1-android'
Run Code Online (Sandbox Code Playgroud)
我遇到了同样的问题。我在下面添加了一行
implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
Run Code Online (Sandbox Code Playgroud)
这有效,但我遇到了另一个问题 -Cannot fit requested classes in a single dex file (# methods: 89411 > 65536)要解决此错误,请确保按如下方式启用 multiDex
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
}
Run Code Online (Sandbox Code Playgroud)
然后最后添加以下几行。
implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
implementation 'androidx.multidex:multidex:2.0.1'
Run Code Online (Sandbox Code Playgroud)
我在“ 如何解决程序类型”中找到了解决方案:com.google.common.util.concurrent.ListenableFuture?。user2297550说:
我只是
implementation 'com.google.guava:guava:27.0.1-android'在我的应用gradle文件的末尾添加了内容,错误消失了。
那是我的解决方案。现在我有了这个,我的应用程序可以正确编译:
implementation 'com.google.firebase:firebase-inappmessaging-display:17.2.0'
implementation 'com.google.guava:guava:27.0.1-android'
Run Code Online (Sandbox Code Playgroud)
减少项目中的重复依赖项
例如,许多依赖项使用 support-v4 和 appcompat-v7 作为包含的包,然后可能是不同的版本,因此您需要从依赖项内部删除这些包并创建一个编译依赖项。
这将删除所有包含的库模块
android {
configurations {
all*.exclude module: 'appcompat-v7'
all*.exclude module: 'support-v4'
}
}
Run Code Online (Sandbox Code Playgroud)
或者您可以管理抛出每个依赖项以更清楚地删除这样的包:
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"
}
}
Run Code Online (Sandbox Code Playgroud)
所有删除的依赖项都必须在 mapbox 之外声明为一份副本,以便所有库使用它们。
| 归档时间: |
|
| 查看次数: |
1350 次 |
| 最近记录: |