java 无法解析符号 AndroidScheduler

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40690369/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 05:25:20  来源:igfitidea点击:

Cannot resolve symbol AndroidSchedulers

javaandroidrx-javarx-java2

提问by syfy

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

我使用的是 RxJava 2.0.0 版,但似乎无法访问AndroidSchedulers. 我无法通过 RxJava 访问主线程

回答by Maksim Ostrovidov

AndroidSchedulersclass is a part of RxAndroidlibrary. Add it to your app's build.gradle:

AndroidSchedulers类是RxAndroid图书馆的一部分。将它添加到您的应用程序的build.gradle

before Gradle v3.0:

在 Gradle v3.0 之前:

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

since Gradle v3.0:

从 Gradle v3.0 开始:

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

回答by Anuraag Patil

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

听起来很奇怪,但它有效

回答by Vinay John

def rxJavaVersion = '2.1.1'

//Add to dependencies the following libraries

dependencies {

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

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

}

回答by canerkaseler

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:

我有同样的问题。您不能使用 RxJava3 调用 AndroidScheduler。我认为这是一个错误。他们需要修复它。您需要将它们添加到您的 gradle 依赖项中:

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

//RxJava
implementation 'io.reactivex.rxjava2:rxjava:2.2.10'

@canerkaseler

@canerkaseler