Duplicate Class Com.Google.Common.Util.Concurrent.Listenable
future Found in Modules Guava-20.0.Jar (Com.Google.Guava:Guava:20.0)

Duplicate class com.google.common.util.concurrent.ListenableFuture found in modules guava-20.0.jar (com.google.guava:guava:20.0)

I found the solution at How to solve Program type already present: com.google.common.util.concurrent.ListenableFuture?. user2297550 said:

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.

That was the solution for me. Now I have this and my app compiles correctly:

implementation 'com.google.firebase:firebase-inappmessaging-display:17.2.0'
implementation 'com.google.guava:guava:27.0.1-android'

Duplicate class com.google.common.util.concurrent.ListenableFuture found in modules jetified-guava-26.0-android.jar

I think part of the issue is that Android Studio (or maybe the Gradle Plugin, however that is handled) is recommending to update the version of the Firestore dependency to 21.4.1 (likely depends on the order of repositories in your build.gradle - not sure on that). And yes, it seems that 21.4.1 causes the issue.

Gradle upgrade recommendation for Firestore lib to 21.4.1

So yeah, just ignore that recommendation and leave it at 21.4.0. Also...

  1. Firebase Docs show 21.4.0 as the correct version.
  2. MVN Repository shows 21.4.1 as the latest release.
  3. Google Maven Repo also lists 21.4.1 as the latest release.

Android Studio - Duplicate classes ... found in modules ... and

I have found the answer to this myself.
It turns out it has to do with certain firebase implementations.

Google has created a package to counter this
To solve this conflict, simply add this to your app-level build.gradle;

implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'

Duplicate jar (ListenableFuture.class) while migrating to New Place SDK google

SOLVED: Finally found a solution. I stated earlier listenable future duplication was found while adding new dependency library for places SDK, duplicate being in the AppCompat library.

I was using the latest AppCompat library and here was the problem. It seems as per google docs, stable version is 1.0.0. So once I revert back everything to the stable version, the problem was solved.

implementation 'androidx.appcompat:appcompat:1.0.0'

And no need of below:

configurations {
all*.exclude group: 'com.google.guava', module: 'listenablefuture'
}

Flutter building apk: Duplicate class found in modules guava-26.0-android.jar and listenablefuture-1.0.jar

Solution taken from this stackoverflow post.

2020 Solution

Google knows about this error so they made a special package to fix the conflict.

Add this to your build.gradle

implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'

Program type already present: com.google.common.util.concurrent.ListenableFuture

Found the problem and the answer. Looking at the External Libraries in the Project view I found the following:

Gradle: com.google.guava:guava:23.5-jre@jar 
|_ guava-23.5-jre.jar
|_com.google
|_common
|_util.concurrent
|_ListenableFuture

Gradle: com.google.guava:listenablefuture:1.0@jar
|_listenablefuture-1.0.jar
|_com.google.common.util.concurrent
|_ListenableFuture

The only thing in the second entry was the duplicate ListenableFuture.

By making the following entry in the gradle build file, this problem went away:

configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == "com.android.support") {
if (!requested.name.startsWith("multidex")) {
details.useVersion "26.+"
}
}
}

all*.exclude group: 'com.google.guava', module: 'listenablefuture' <===This fixed the problem
}

I could not figure out what was generating the com.google.guava:listenablefuture:1.0@jar, but the resulting problem was solved.

Thanks for all who reviewed the problem.

Duplicate class com.google.common found in modules guava error after migrating to Androidx

After many hours of research I found the solution. The problematic dependency was this:

'com.google.apis:google-api-services-youtube:v3-rev204-1.23.0'

I solved it by using:

implementation ('com.google.apis:google-api-services-youtube:v3-rev204-1.23.0'){
exclude group:'com.google.guava'
}

If you face a similar issue, try to create a new Android project and import only the dependencies from your previous project. Then divide and conquer until you find the problematic dependency.

Cannot access class 'com.google.common.util.concurrent.ListenableFuture' in Flutter project

After posting a question I was actually able to figure it out. Suggestions from SO question mentioned above were almost correct, but in my case what I needed to add to native android dependencies in app build.gradle was whole guava:

implementation "com.google.guava:guava:31.0.1-android"

After that build successfully passes.



Related Topics



Leave a reply



Submit