My app suddenly doesn’t build anymore with this error:
error: package com.google.common.util.concurrent does not exist
import com.google.common.util.concurrent.ListenableFuture;
Why all of the sudden? This was working fine for quite some time. All libraries are up to date. What do I need to do for this to compile again?
Update: this is happening after upgrading
implementation 'com.google.android.gms:play-services-ads:22.3.0'
to
implementation 'com.google.android.gms:play-services-ads:22.4.0'
going back to version 22.3.0 and everything is fine. Is this a bug in the ads library? Some weird version mixup of different library versions, maybe with room or whatever?
2
Answers
You could add an explicit dependency if you need
ListenableFuture
.https://developer.android.com/guide/background/asynchronous/listenablefuture
This seems to be intentional on Google’s part. I’ve taken a look at the maven repository page for the artifact for both the
22.3.0
version and22.4.0
, and the latter has a compile dependency on listenablefuture that is ’empty to avoid conflict with Guava`. It looks a little bit ambiguous so here is what the dependency says in its description (again, this dependency does NOT exist in 22.3.0):This was taken from here ListenableFuture empty dependency.
Ideally, if you want to use ListenableFuture, you would declare the Guava dependency but if you only need
ListenableFuture
, you may depend on the aforementioned artifact instead, as it seems to do the job. This is it:implementation("com.google.guava:listenablefuture:1.0")