gpt4 book ai didi

java - 房间内可流动

转载 作者:行者123 更新时间:2023-11-30 05:20:17 26 4
gpt4 key购买 nike

@Database(entities = {User.class}, version = 2, exportSchema = false)
public abstract class AppDatabase extends RoomDatabase {
public abstract userDao userDao();
}

Pojo 用户类

@Entity
public class User {
@PrimaryKey(autoGenerate = true)
private int id;

public User(){
}



public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}
}

@Dao
public interface userDao {
@Query("SELECT * FROM User WHERE id = :id")
Flowable<User> get(int id);
@Insert
Completable insert(User user);
}

依赖关系

implementation "androidx.room:room-runtime:2.2.3"
annotationProcessor "androidx.room:room-compiler:2.2.3"
implementation "android.arch.persistence.room:rxjava2:1.1.1"
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation "io.reactivex.rxjava2:rxjava:2.2.14"

错误

error: no suitable method found for createFlowable(RoomDatabase,boolean,String[],<anonymous Callable<User>>)
method RxRoom.createFlowable(RoomDatabase,String...) is not applicable
(varargs mismatch; boolean cannot be converted to String)
method RxRoom.<T>createFlowable(RoomDatabase,String[],Callable<T>) is not applicable
(cannot infer type-variable(s) T
(actual and formal argument lists differ in length))
where T is a type-variable:
T extends Object declared in method <T>createFlowable(RoomDatabase,String[],Callable<T>)

我试图弄清楚如何在房间中使用 rxjava,我按照示例进行操作,但它抛出错误,问题是什么?完成效果很好

最佳答案

我不知道您为什么将 ianhanniballake 的答案标记为正确答案。
依赖项“androidx.room:room-ktx:2.2.3”与 RxJava 无关。
我的情况是通过添加此依赖项解决了问题

implementation "androidx.room:room-rxjava2:2.2.3"

安装了我的旧的:

implementation 'android.arch.persistence.room:rxjava2:1.1.1' 

希望这会有所帮助

关于java - 房间内可流动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59699286/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com