ExoPlayer dependencies make com.google.common not available

Created on 26 Sep 2020  路  2Comments  路  Source: google/ExoPlayer

[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?

question

Most helpful comment

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'

All 2 comments

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'

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

Was this page helpful?
0 / 5 - 0 ratings