【问题标题】:Using Room-Guava in Android, cannot find ListenableFuture在 Android 中使用 Room-Guava,找不到 ListenableFuture
【发布时间】:2022-08-17 00:19:04
【问题描述】:

我正在关注这个: https://developer.android.com/training/data-storage/room/async-queries

我正在尝试使用可听的未来来自番石榴,所以我包括androidx.room: 房间番石榴但 Android Studio 一直在抱怨“无法解析符号 \'ListenableFuture\'\" 并且不建议任何相关的import

包含在 Java 源代码中的正确 import 是什么?

这是我的代码:


build.gradle(:app)

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

Java DAO 接口

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

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

    标签: android-room guava


    【解决方案1】:

    根据https://mvnrepository.com/artifact/androidx.room/room-guava/2.4.3androidx.concurrent:concurrent-futures 是运行时依赖项。请检查https://mvnrepository.com/artifact/androidx.concurrent/concurrent-futures 是否存在。 ListenableFuture 来自它的传递依赖 https://mvnrepository.com/artifact/com.google.guava/listenablefuture/1.0

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-31
      • 2018-03-11
      • 2011-08-20
      相关资源
      最近更新 更多