I'm trying to use RXJava2 with Room database . I use Single Observable to get a list of my object . But every time I get this error
cannot find symbol class EmptyResultSetException
I'm using this tutorial ANDROID ROOM PERSISTENT AND RXJAVA2
I used it before with AsyncTask without RXJava and it worked so I wanted to use it with RXJava
Here is my 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'
}
Dao Class
@Query("SELECT * FROM UserEntity")
Single<List<UserEntity>> getUsersSingle();
MyActivity
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());
}
});
I solved the problem according to this Answer
I just changed the room_version to 1.1.0 . By the way I'm waiting for any one who can explain this error or just explain why it happened .