Reactive Programming with RxAndroid in Kotlin: An Introduction |

Learn about how Reactive programming is a whole new paradigm using RxJava and RxAndroid in Android with Kotlin.

This is a companion discussion topic for the original entry at

You can use doFinally to dismiss the progress dialog, it is called if an item is emitted or on error.

This is a really good tutorial to finally get one’s head around Rx.

I found a problem in the section for Maybe

In the example, the last few lines look like this:

.subscribe {
   holder.itemView.imageFavorite.isChecked = it == 1 // 6

This causes an error:
io.reactivex.exceptions.OnErrorNotImplementedException: Only the original thread that created a view hierarchy can touch its views.

I think you want it to use observeOn, like this:

.subscribe {
  holder.itemView.imageFavorite.isChecked = it == 1

@kandroidj Can you please help with this when you get a chance? Thank you - much appreciated! :]

Hello! Thank you for this tutorial, it is a great way to get started with reactive programming :slight_smile:

I found an issue on the section “Observe Button Clicks”. Here, we end with the app running database queries on the UI thread (which is what you intend). However, Android API 28 throws an IllegalStateException and does not let you execute the query at all (the app crashes when you press the button).
A quick fix for this (before you show us how to use threading on the next section) is adding the modifying the code for building the database instance:

INSTANCE = Room.databaseBuilder(context,, “cheese.db”).allowMainThreadQueries()

This allows you to see the progress so far.

1 Like

@rva5120 Thank you for sharing your solution - much appreciated! :]

I am getting ‘Gradle project sync failed’ error after downloading ‘’ cheesefinder-starter" project. Cause of error is ‘org/gradle/internal/impldep/com/google/common/collect/Lists’. Anybody can help me to solve this issue?

@kandroidj Do you have any feedback about this? Thank you - much appreciated! :]

This tutorial is more than six months old so questions are no longer supported at the moment for it. Thank you!