Unresolved reference: Observable in Android Studio

2019-07-20 07:51发布

Updated to Android Studio 3.4, with Gradle 5.1.1 and Kotlin 1.3.10 as minimum versions. Cannot run project anymore due to reactivex.Observable not being found. Has anyone found a solution?

Was using rxBinding lib, also tried using latest vesions RxJava 2.2.8 and RxAndroid 2.1.1 with no success.

5条回答
ゆ 、 Hurt°
2楼-- · 2019-07-20 08:37

Along with the dependency of RxKotlin use this

api 'io.reactivex.rxjava2:rxjava:2.2.0'

Only works for Gradle 5.0 or above

查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-07-20 08:46

Downgrading the build.gradle(project) from classpath 'com.android.tools.build:gradle:3.4.0' to classpath 'com.android.tools.build:gradle:3.2.1' might be help you

查看更多
看我几分像从前
4楼-- · 2019-07-20 08:47

The accepted answer ended up leading me to the solution: leaving the gradle-wrapper.properties intact and don't increase the gradle version at all. We'll see if a future lib update will solve it for gradle 3.4.

查看更多
够拽才男人
5楼-- · 2019-07-20 08:49

The issue is that you need to use RxJava 2.2.8 and if you check the RxAndroid gradle file they are using the RxJava version 2.2.6 :

https://github.com/ReactiveX/RxAndroid/blob/2.x/rxandroid/build.gradle

If you force RxJava to use version 2.2.8 it will work.

Add to gradle:

implementation 'io.reactivex.rxjava2:rxjava:2.2.8
查看更多
三岁会撩人
6楼-- · 2019-07-20 08:51

Yeah the workaround* for me was to downgrade from gradle 5.1.1 to 4.10.1 and also to the latest android gradle plugin prior to 3.4.0, which is 3.3.2.

I did this in gradle/wrapper/gradle-wrapper.properties by changing to the following: distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip

I then also changed the following in my root build.gradle file:

'com.android.tools.build:gradle:3.4.0' to 'com.android.tools.build:gradle:3.3.2'

查看更多
登录 后发表回答