Java 如何解决“程序类型已经存在:com.google.common.util.concurrent.ListenableFuture”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/52521302/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to solve 'Program type already present: com.google.common.util.concurrent.ListenableFuture'?
提问by Simran Marok
I am trying to use WorkManager 1.0.0-alpha09. and getting this error:
我正在尝试使用 WorkManager 1.0.0-alpha09。并收到此错误:
Program type already present:
com.google.common.util.concurrent.ListenableFuture
Message{kind=ERROR, text=Program type already present:
com.google.common.util.concurrent.ListenableFuture, sources=[Unknown source
file], tool name=Optional.of(D8)}
If i use version 1.0.0-alpha08 or less. I don't get this error, but i need public constructor
如果我使用 1.0.0-alpha08 或更低版本。我没有收到此错误,但我需要公共构造函数
public Worker(Context context, WorkerParameters workerParams)
采纳答案by Rahul
Take a look at https://issuetracker.google.com/issues/116154359.
看看https://issuetracker.google.com/issues/116154359。
The workaround is:
解决方法是:
implementation("android.arch.work:work-runtime:1.0.0-alpha09") {
exclude group: 'com.google.guava', module: 'listenablefuture'
}
回答by Anggrayudi H
In my case, I had to add the following configurations to app's module build.gradle
:
就我而言,我必须将以下配置添加到 app 的模块中build.gradle
:
configurations {
all*.exclude group: 'com.google.guava', module: 'listenablefuture'
}
It happens because some dependencies use com.google.guava:guava
and com.google.guava:listenablefuture
together. It causes a dependency conflict.
发生这种情况是因为某些依赖项一起使用com.google.guava:guava
和com.google.guava:listenablefuture
。它会导致依赖冲突。
回答by user2297550
I merely added implementation 'com.google.guava:guava:27.0.1-android'
at the end of my app gradle file and the error went away.
我只是implementation 'com.google.guava:guava:27.0.1-android'
在我的应用程序 gradle 文件的末尾添加,错误就消失了。
回答by Vraj Parikh
I am using ListenableFuture
that comes from the work manager.
我正在使用ListenableFuture
来自工作经理的。
implementation("android.arch.work:work-runtime:1.0.0")
So excluding exclude group: 'com.google.guava', module: 'listenablefuture'
, didn't work for me.
所以排除exclude group: 'com.google.guava', module: 'listenablefuture'
,对我不起作用。
I was using a dependency that internally used androidTestImplementation "com.google.truth:truth:42"
that internally used com.google.guava:guava:25.0.1-android
. This was causing the problem for me.
我正在使用内部使用的依赖项androidTestImplementation "com.google.truth:truth:42"
,内部使用的com.google.guava:guava:25.0.1-android
. 这给我造成了问题。
Upgrading com.google.truth:truth
to 43
solved it for me.
升级com.google.truth:truth
到43
解决了这个问题对我来说。