开发者社区> 问答> 正文

室内流动

@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,我按照示例进行操作,但是会引发错误,这是什么问题?完成作品很好

展开
收起
Puppet 2020-01-12 09:16:59 712 0
1 条回答
写回答
取消 提交回答
  • 根据“ 房间声明依赖项”文档,您需要依赖room-ktx才能使用协程,并且Flowable:

    
    implementation "androidx.room:room-ktx:2.2.3"
    
    2020-01-12 09:17:17
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
液体活检,精准分析 立即下载
驾驭时空中国⾸辆⾃动驾驶低速电动⻋发布 立即下载
短距离无线系统与航空无 线电系统攻击 立即下载