lcj
lcj

Reputation: 1797

Cannot resolve symbol 'AndroidSchedulers ' on AndroidSchedulers.mainThread() using implementation 'androidx.room:room-rxjava2:2.1.0'

I am trying to follow a few code examples to pull a single record from the database to display, because it seems somewhat complicated to do so with LiveData. However, I am getting an error in the IDE.

Cannot resolve symbol 'AndroidSchedulers'

on the line:

AndroidSchedulers.mainThread()

in this call:

        viewModel.getScenario(scenarioId)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new DisposableSingleObserver<Scenario>() {
                    @Override
                    public void onSuccess(Scenario scenario) {

                    }
                });

My grade has this:

implementation 'androidx.room:room-rxjava2:2.1.0'

Upvotes: 0

Views: 1331

Answers (1)

KuLdip PaTel
KuLdip PaTel

Reputation: 1069

You have missing implementation 'io.reactivex.rxjava2:rxandroid:2.1.1' in your gradle. AndroidSchedulers.mainThread() is part of rxandroid not a rxjava2

Upvotes: 6

Related Questions