Android dependency 'io.reactivex.rxjava2:rxandroid' has different version

2.4k views Asked by At

When sync project with gradle files, Android Studio shows this error:

Android dependency 'io.reactivex.rxjava2:rxandroid' has different version for the compile (2.0.1) and runtime (2.1.0) classpath. You should manually set the same version via DependencyResolution

I have try to solve it with:

resolutionStrategy.force 'io.reactivex.rxjava2:rxandroid:2.1.0'

But with the same result.

This problem occurs when I change 'compile' with 'implementation' in the libraries definition

This is how I define the rest of the rx libraries:

buildscript {

    ext.retrofitVersion = '2.4.0'
    ext.rxVersion = '2.2.1'
    ext.rxAndroidVersion = '2.1.0'
    ext.okhttpVersion = '3.8.1'
    ext.rxKotlinVersion = '2.0.0'

    ...


    repositories {
        mavenCentral()
        jcenter()
    }

}
//Rx & Retrofit 2 **********************************
implementation("com.squareup.retrofit2:retrofit:$retrofitVersion") {
    // exclude Retrofit’s OkHttp peer-dependency module and define your own module import
    exclude module: 'okhttp'
}
implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"
implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion"
implementation "io.reactivex.rxjava2:rxkotlin:$rxKotlinVersion"
implementation "com.squareup.okhttp3:okhttp:$okhttpVersion"
implementation "com.squareup.okhttp3:logging-interceptor:$okhttpVersion"
implementation "io.reactivex.rxjava2:rxandroid:${rxAndroidVersion}"
implementation "io.reactivex.rxjava2:rxjava:$rxVersion"

Any ideas how can I solve this problem?

1

There are 1 answers

0
Sami Issa On BEST ANSWER

Ok, finally I solved the problem following the @yayo-arellano solution. I was to replace "implementation" by "api".