Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix problem with ListenableFuture conflict if other libraries use guava #136

Closed
wants to merge 4 commits into from

Conversation

MichalTorma
Copy link

Hi, I put together some fixes that I needed to make this run in my project - there is an issue with using androidx.work:work-runtime which is dependant on com.google.common.util.concurrent.ListenableFuture if some of the other libraries in the project depend on com.google.guava (which also contains ListenableFuture class). This resulted in the following error:
Duplicate class com.google.common.util.concurrent.ListenableFuture found in modules guava-20.0.jar

There is also a fix of testInstrumentationRunner library in build.gradle which was not compliant with androidX

Lastly, I put in the gradle wrapper 5.4.1 but that was because android studio was annoying me to do it - Not sure if it's needed though.

I didn't manage to build your example project but all seems to be working in in mine.

Best regards

@probot-autolabeler probot-autolabeler bot added the android Android specific label Jan 9, 2020
@petermnt
Copy link
Contributor

petermnt commented Jan 9, 2020

This does not sound like the correct solution.
This way we exclude a dependency for everyone, while I assume everyone needs it.

If your other dependency which uses ListenableFuture would expose it properly through the .pom-file gradle will pick this up correctly.
I imagine you have another dependency which actually has a compiled version of ListanableFuture inside, which is incorrect.

So it will need to be fixed at the plugin that uses compiled dependences instead of .pom dependencies.

Also, there shouldn't be gradlew files in the android plugin directory. The plugin needs to be built through the example app.

Is there anything I'm missing? Otherwise I will close this PR.

@MichalTorma
Copy link
Author

Thanks for the clarification :) I'm obviously just learning the ropes here. You can close this.

@MichalTorma
Copy link
Author

MichalTorma commented Jan 10, 2020

Could you please elaborate a bit more on the issue? After a bit of detective work, I found that the conflicting package is google_sign_in. They don't use compiled guava dependency - it's just a normal dependency in build.gradle file. Yet this is a known issue with guava that they made their own listenablefuture which is in conflict with com.google.common.util.concurrent.ListenableFuture (which is in turn used by androidx work-runtime library that you use) It's a bit of a mess...

After testing the solution with

implementation("androidx.work:work-runtime:$work_version") {
    exclude group: 'com.google.guava', module: 'listenablefuture' 

I don't see any errors with google_sign_in library, therefore, I presume this excludes guava only for your library and not for the whole project. But I'm not really that familiar with gradle (who is...) and my assumptions might be wrong here.

Yet the issue stands that your library does not compile with google_sign_in library which I think is worth figuring out.

@MichalTorma MichalTorma reopened this Jan 10, 2020
@petermnt
Copy link
Contributor

Excluding it like this in our build.gradle file means people who don't use google sign-in won't get the dependency.
The easiest solution for you would be to use the exclude on the Google Sign-In dependency in your build.gradle file.

Another thing I can point you to is using ./gradlew :app:dependencies in your project. There you will see the dependency graph and can see if google sign-in correctly defines the dependency.

@petermnt petermnt added the answered Used to auto-close 'answered' issues after a certain time of inactivity label Jan 10, 2020
@MichalTorma
Copy link
Author

That makes sense. You might consider adding a note to the documentation about it. Once I added configurations { all*.exclude group: 'com.google.guava', module:'listenablefuture' }
to my build.gradle - it works. I still don't know how it would behave if guava:listenablefuture is actually required by some library (I'd guess it fails)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android Android specific answered Used to auto-close 'answered' issues after a certain time of inactivity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants