Cannot resolve symbol AndroidSchedulers
Asked Answered
B

5

32

I'm using version 2.0.0 of RxJava, and it seems like I have no access to AndroidSchedulers. I'm unable to get access to mainthread through RxJava

Binominal answered 19/11, 2016 at 7:33 Comment(0)
I
57

AndroidSchedulers class is a part of RxAndroid library. Add it to your app's build.gradle:

before Gradle v3.0:

compile 'io.reactivex.rxjava2:rxandroid:2.0.1'

since Gradle v3.0:

implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
Indulge answered 19/11, 2016 at 7:35 Comment(0)
D
9

I had same problem. You cannot call AndroidSchedulers with RxJava3. I think this is a bug. They need to fix it.

You need to add they on your dependencies of gradle:

//RxAndroid
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'

//RxJava
implementation 'io.reactivex.rxjava2:rxjava:2.2.10'
Delafuente answered 20/4, 2020 at 16:5 Comment(1)
I had the same issue. For RxJava3, it looks like you need both the rxjava3 and rxandroid3 implementation.implementation "io.reactivex.rxjava3:rxjava:3.1.1" implementation "io.reactivex.rxjava3:rxandroid:3.0.0"Gomar
S
8

Go back to Old Versions:

compile 'io.reactivex:rxandroid:1.2.1'   
compile 'io.reactivex:rxjava:1.1.6'

Then to the Newer Version:

compile 'io.reactivex.rxjava2:rxandroid:2.0.1'    
compile 'io.reactivex.rxjava2:rxjava:2.1.1'

Sounds Weird but it works

Shortening answered 15/5, 2018 at 19:5 Comment(1)
This is perfectly working, thanks a lot. This is more meaningful and helpful answerGaziantep
I
2
def rxJavaVersion = '2.1.1'

//Add to dependencies the following libraries

dependencies {

  implementation "io.reactivex.rxjava2:rxandroid:$rxJavaVersion"

  implementation "io.reactivex.rxjava2:rxjava:$rxJavaVersion"

}
Indohittite answered 16/3, 2020 at 12:6 Comment(1)
While this code may provide a solution to the question, it's better to add context as to why/how it works. This can help future users learn, and apply that knowledge to their own code. You are also likely to have positive feedback from users in the form of upvotes, when the code is explained.Warily
J
0

Now you can use RX 3 by adding the below dependency

implementation "io.reactivex.rxjava3:rxandroid:$version"

get the version from this link : https://github.com/ReactiveX/RxAndroid

Janellajanelle answered 11/3, 2021 at 16:7 Comment(1)
io.reactivex.rxjava3:rxandroid:3.0.0Liew

© 2022 - 2024 — McMap. All rights reserved.