rxAndroid出现错误。 `错误:升级Gradle,buildToolVersion和compileSdk后,包rx.android.schedulers不存在。
这是我的gradle文件
主要gradle文件
buildscript {
repositories {
jcenter()
google()
maven { url 'http://repo1.maven.org/maven2' }
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath "com.fernandocejas.frodo:frodo-plugin:0.8.1"
classpath 'com.frogermcs.androiddevmetrics:androiddevmetrics-plugin:0.4'
classpath 'com.google.gms:google-services:4.2.0'
}
}
allprojects {
repositories {
jcenter()
}
}
repositories {
maven { url 'http://repo1.maven.org/maven2' }
jcenter()
}
应用gradle文件
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.xxx.xxx"
minSdkVersion 21
targetSdkVersion 27
versionCode 187
versionName "1.0.5"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
dependencies {
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'io.reactivex.rxjava2:rxjava:2.2.7'
implementation group: 'com.squareup.retrofit2', name: 'adapter-rxjava2', version: '2.2.0'
implementation 'com.android.support:multidex:1.0.2'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v13:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.squareup.retrofit2:retrofit:2.1.0'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
}
我的样本用法
//Here is the error
import io.reactivex.android.schedulers.AndroidSchedulers;
compositeSubscription.add(publishRelay.asObservable().observeOn(AndroidSchedulers.mainThread()).subscribe(iView -> {
}
我在网上看了一下,但对我没有用。
任何人都可以建议出什么问题吗
谢谢 R
答案 0 :(得分:0)
您需要更改依赖性
来自
implementation 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
到
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.5.0'