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

7,946 views
Skip to first unread message

alexand...@gmail.com

unread,
Jan 13, 2019, 2:30:34 PM1/13/19
to guava-discuss
Hello,
I have try migrate from Google Drive Android Api to REST api, follow instructions and I got error:
java.lang.RuntimeException: Duplicate class com.google.common.util.concurrent.ListenableFuture found in modules jetified-guava-26.0-android.jar (com.google.guava:guava:26.0-android) and listenablefuture-1.0.jar (com.google.guava:listenablefuture:1.0)

my dependencies in gradle

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    proVersionImplementation "com.google.guava:listenablefuture:1.0"
    proVersionImplementation "com.google.guava:failureaccess:1.0"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
    implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha01'
    implementation "com.google.android.material:material:1.1.0-alpha02"
    implementation "androidx.documentfile:documentfile:1.0.0"
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha01'
    implementation 'androidx.vectordrawable:vectordrawable:1.1.0-alpha01'
    implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
    implementation "androidx.drawerlayout:drawerlayout:1.0.0"
    implementation "org.jetbrains.anko:anko-sdk15:$anko_version"

    implementation "org.jetbrains.anko:anko-appcompat-v7:$anko_version"
    implementation "org.jetbrains.anko:anko-cardview-v7:$anko_version"
    implementation "org.jetbrains.anko:anko-recyclerview-v7:$anko_version"
    implementation "org.jetbrains.anko:anko-design:$anko_version"
    proVersionImplementation ('com.google.android.gms:play-services-auth:16.0.1') {
    }
    proVersionImplementation ('com.google.http-client:google-http-client-gson:1.28.0') {
    }
    proVersionImplementation('com.google.api-client:google-api-client-android:1.27.0') {
        exclude group: 'org.apache.httpcomponents'
    }
    proVersionImplementation('com.google.apis:google-api-services-drive:v3-rev99-1.23.0') {
        exclude group: 'org.apache.httpcomponents'
    }
    implementation 'org.apache.commons:commons-lang3:3.8.1'
    implementation 'androidx.multidex:multidex:2.0.1'

}

Help please
Thanks
Alexander

Joachim Durchholz

unread,
Jan 13, 2019, 3:51:16 PM1/13/19
to guava-...@googlegroups.com
Am 13.01.19 um 20:30 schrieb alexand...@gmail.com:
> Hello,
> I have try migrate from Google Drive Android Api to REST api, follow
> instructions and I got error:
> java.lang.RuntimeException: Duplicate class
> com.google.common.util.concurrent.ListenableFuture found in modules
> jetified-guava-26.0-android.jar (com.google.guava:guava:26.0-android)
> and listenablefuture-1.0.jar (com.google.guava:listenablefuture:1.0)
This is a build problem, not a Guava problem. It happens if the same
class is pulled in from multiple different jars.
You'll have to find out why Gradle is pulling both jars and either get
rid of one of them or make sure the classes are identical and suppress
the error - there's too much detail about this to go into it, please ask
in a Gradle forum.

Regards,
Jo

Jonathan Bluett-Duncan

unread,
Jan 20, 2019, 11:18:37 AM1/20/19
to alexand...@gmail.com, guava-discuss, Joachim Durchholz
Hi Alexander,

To add to Joachim's response, I wonder if your problem stems from the Guava team's recent decision to split ListenableFuture away from Guava as discussed in this issue and this mailing list thread.

Have you tried removing the com.google.guava:listenablefuture:1.0 artifact from your dependencies? If so, what impact does that have?

This while thread makes me wonder further if the decision to split ListenableFuture away from Guava was the right thing to do, at least for the -jre version, as it seems to be introducing confusion as to how com.google.guava:listenablefuture:1.0 should be used.

I don't have Chris Povirk's email address so I can't directly include him, but in the hope that he's subscribed to this thread, I'm just wondering out loud if he or anyone else on the Guava team any further thoughts regarding all this?

Cheers,
Jonathan


--
guava-...@googlegroups.com
Project site: https://github.com/google/guava
This group: http://groups.google.com/group/guava-discuss

This list is for general discussion.
To report an issue: https://github.com/google/guava/issues/new
To get help: http://stackoverflow.com/questions/ask?tags=guava
---
You received this message because you are subscribed to the Google Groups "guava-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to guava-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/guava-discuss/15db50d4-3973-26b6-817e-d09456fb121a%40durchholz.org.
For more options, visit https://groups.google.com/d/optout.

alexand...@gmail.com

unread,
Jan 21, 2019, 1:52:50 PM1/21/19
to guava-discuss
I have added to dependecies this:
proVersionImplementation group: 'com.google.guava', name: 'guava', version: '27.0.1-android'
and problem is solved.

Dňa nedeľa, 13. januára 2019 20:30:34 UTC+1 alexand...@gmail.com napísal(-a):

Chris Povirk

unread,
Jan 22, 2019, 1:38:14 PM1/22/19
to alexand...@gmail.com, guava-discuss
Sorry for the trouble. Adding the dep on 27.0.1-android is what we'd recommend. (Or you can exclude listenablefuture if that's easier.)

alexand...@gmail.com

unread,
Jan 28, 2019, 6:45:05 PM1/28/19
to guava-discuss
exclude listenablefuture doesn't work for me

Dňa utorok, 22. januára 2019 19:38:14 UTC+1 Chris Povirk napísal(-a):

bria...@gmail.com

unread,
Jul 15, 2019, 12:17:33 AM7/15/19
to guava-discuss
Hi Alex,

May I know if you have found the solution yet?  I have the same issue =(

Thanks,
Brian

alexand...@gmail.com

unread,
Aug 3, 2019, 3:49:47 PM8/3/19
to guava-discuss
As I mentioned upper,
I have added to dependecies this:
proVersionImplementation ('com.google.guava:guava:28.0-android') {
exclude group: 'org.apache.httpcomponents'
exclude group: "com.google.guava:listenablefuture:1.0"
}

Dňa pondelok, 15. júla 2019 6:17:33 UTC+2 bria...@gmail.com napísal(-a):

sak...@gmail.com

unread,
Mar 9, 2020, 4:10:02 PM3/9/20
to guava-discuss
It worked for me too!!!
I just added implementation group: 'com.google.guava', name: 'guava', version: '27.0.1-android' into my dependencies.

Kajal Arya

unread,
Jun 3, 2021, 1:32:47 AM6/3/21
to guava-discuss
Hello Everyone ,i didn't added this type of dependency then why did i get this error?
i m unable to resolve this error , provide me any solution

Hong Zhang

unread,
Jan 7, 2022, 5:33:47 PM1/7/22
to guava-discuss
Thank you all for the tips that led to the solution for me:
   implementation group: 'com.google.guava', name: 'guava', version: '30.1.1-android'

The following did not work:
implementation('com.google.guava:guava:30.1.1-android') {
 exclude group: "com.google.guava"
 exclude group: 'org.apache.httpcomponents'
 exclude group: "com.google.guava:listenablefuture:1.0"
}

Reply all
Reply to author
Forward
0 new messages