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

Simran Marok picture Simran Marok · Sep 26, 2018 · Viewed 14.2k times · Source

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)

Answer

Anggrayudi H picture Anggrayudi H · Jan 1, 2019

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.