How to solve 'Program type already present: com.google.common.util.concurrent.ListenableFuture'?

我与影子孤独终老i 提交于 2019-11-26 19:56:08

问题


I am trying to use WorkManager 1.0.0-alpha09. and getting this error:

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

public Worker(Context context, WorkerParameters workerParams)

回答1:


Take a look at 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' 
}



回答2:


In my case, I had to add the following configurations to app's module 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.




回答3:


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.




回答4:


I am using ListenableFuture that comes from the work manager.

implementation("android.arch.work:work-runtime:1.0.0")

So excluding exclude group: 'com.google.guava', module: 'listenablefuture', didn't work for me.

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.

Upgrading com.google.truth:truth to 43 solved it for me.



来源:https://stackoverflow.com/questions/52521302/how-to-solve-program-type-already-present-com-google-common-util-concurrent-li

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!