gpt4 book ai didi

java - 将 Android Room 数据库与 RXJava2 一起使用时找不到符号类 EmptyResultSetException

转载 作者:行者123 更新时间:2023-12-01 20:15:44 25 4
gpt4 key购买 nike

我正在尝试将 RXJava2Room 数据库 一起使用。我使用 Single Observable 来获取我的对象的列表。但每次我都会收到这个错误

cannot find symbol class EmptyResultSetException

我正在使用本教程 ANDROID ROOM PERSISTENT AND RXJAVA2

我之前在没有RXJava的情况下将它与AsyncTask一起使用,并且它有效,所以我想将它与RXJava一起使用

这是我的build.gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
applicationId "apit.net.sa.simpleusingroom"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'




implementation 'com.android.support:support-v13:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.jakewharton:butterknife:8.5.1'
//ROOM database
implementation 'android.arch.persistence.room:runtime:1.0.0'
annotationProcessor 'android.arch.persistence.room:compiler:1.0.0'

//RXJava2
implementation 'io.reactivex.rxjava2:rxjava:2.1.9'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'

//RXjava with room
implementation 'android.arch.persistence.room:rxjava2:1.0.0-alpha1'

annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

道类

 @Query("SELECT * FROM UserEntity")
Single<List<UserEntity>> getUsersSingle();

我的 Activity

DatabaseSingInstance.getInstance(this)
.getOurDatabase()
.userDAO()
.getUsersSingle()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new DisposableSingleObserver<List<UserEntity>>() {


@Override
public void onSuccess(final List<UserEntity> userEntities) {
adapter = new UserAdapter(userEntities, MainActivity.this, new UserAdapter.OnLongClickListner() {
@Override
public void onClick(int position) {
showPopupWindow(userEntities,position);
}
});
myRec.setAdapter(adapter);
}

@Override
public void onError(Throwable e) {
Log.e("error"," "+e.getMessage());
}


});

最佳答案

我按照这个Answer解决了问题

我刚刚将 room_version 更改为 1.1.0 。顺便说一句,我正在等待任何人能够解释此错误或只是解释它发生的原因。

关于java - 将 Android Room 数据库与 RXJava2 一起使用时找不到符号类 EmptyResultSetException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58954911/

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