简体   繁体   中英

Using Room-Guava in Android, cannot find ListenableFuture

I'm following this: https://developer.android.com/training/data-storage/room/async-queries

I'm trying to use ListenableFuture from Guava, so I included androidx.room:room-guava but Android Studio keeps complaining that " Cannot resolve symbol 'ListenableFuture' " and doesn't suggest any relevant import .

What is the correct import to include in Java source?

Here is my code:


build.gradle(:app)

...
// Guava support for Room, including Optional and ListenableFuture
implementation "androidx.room:room-guava:2.4.3"

Java DAO interface

import androidx.room.Dao;
import androidx.room.Insert;

@Dao
public interface PressureMeasureDao
{
    @Insert
    public ListenableFuture<Integer> insertPressureMeasure(PressureMeasure pressureMeasure);
}

According to https://mvnrepository.com/artifact/androidx.room/room-guava/2.4.3 androidx.concurrent:concurrent-futures is a runtime dependency. Please check if https://mvnrepository.com/artifact/androidx.concurrent/concurrent-futures is present. ListenableFuture comes from its transitive dependency https://mvnrepository.com/artifact/com.google.guava/listenablefuture/1.0 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM