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

ExoPlayer dependencies make com.google.common not available #7993

Closed
ccparram opened this issue Sep 26, 2020 · 2 comments
Closed

ExoPlayer dependencies make com.google.common not available #7993

ccparram opened this issue Sep 26, 2020 · 2 comments
Assignees
Labels

Comments

@ccparram
Copy link

ccparram commented Sep 26, 2020

[REQUIRED] Issue description

After adding ExoPlayer dependencies com.google.common is not longer available.

image

If you remove ExoPlayer dependencies the package is avaiable.

[REQUIRED] Reproduction steps

Add CameraX dependencies
Add ExoPlayer dependencies

[REQUIRED] Link to test content

Example Repo with issue
This repo has 2 commits. ExoPlayer dependencies are added in the last one.

[REQUIRED] Version of ExoPlayer being used

2.12.0

[REQUIRED] Device(s) and version(s) of Android being used

Android Studio 4.0.1

Why is this happening?

@icbaker
Copy link
Collaborator

icbaker commented Sep 28, 2020

Thanks for the example project, I can repro your problem.

I believe this is related to Guava publishing ListenableFuture in both com.google.guava:listenablefuture:1.0 and com.google.guava:guava:XX.X-android. This risks causing clashes (different bytecode for the same class name), so they created com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava which com.google.guava:guava:XX.X-android depends on. This 9999.0 dependency is empty, it doesn't actually contain the ListenableFuture interface.

There's some more info about this in the Duplication troubles section here: https://blog.gradle.org/guava

It looks like CameraX declares com.google.guava:listenablefuture:1.0 as an api dependency - meaning it's visible to libraries depending on CameraX (i.e. your app).

ExoPlayer 2.12.0 declares com.google.guava:guava:27.1-android as an implementation dependency - meaning it's not visible to your app.

Gradle's version resolution "correctly" replaces CameraX's listenablefuture:1.0 with listenablefuture:9999.0-empty-to-avoid-conflict-with-guava (via ExoPlayer's Guava dep). However, since this dep is actually empty this suddenly means your app can't see the ListenableFuture class any more (hence the build errors).

You can fix this by directly depending on Guava from your app's build.gradle:

// Guava
implementation 'com.google.guava:guava:29.0-android'

@ccparram
Copy link
Author

Here again just to say thank you @icbaker. Your answer was perfect.

ojw28 pushed a commit that referenced this issue Oct 17, 2020
The 'implementation' dependency causes problems when resolving
ListenableFuture in contexts that also include the
com.google.guava:listenablefuture:1.0 dependency.

Issue: #7905
Issue: #7997
Issue: #7993
PiperOrigin-RevId: 337093024
ojw28 pushed a commit that referenced this issue Oct 21, 2020
The 'implementation' dependency causes problems when resolving
ListenableFuture in contexts that also include the
com.google.guava:listenablefuture:1.0 dependency.

Issue: #7905
Issue: #7997
Issue: #7993
PiperOrigin-RevId: 337093024
@google google locked and limited conversation to collaborators Dec 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants