Cannot resolve rxjava2 with gradle 3.0

Alexander Tumanin picture Alexander Tumanin · Nov 14, 2017 · Viewed 8.3k times · Source

Hare is my app gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.atumanin.testandroidannotations"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.1.18"

        javaCompileOptions {
            annotationProcessorOptions {
                includeCompileClasspath true
            }
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'io.reactivex.rxjava2:rxjava:2.1.6'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
}

and this is my project gradle:

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

If I try to build project, I get error:

Could not resolve io.reactivex.rxjava2:rxjava:2.1.6.

and

Could not resolve io.reactivex.rxjava2:rxandroid:2.0.1.

I tried to clean, to rebuild the project and to invalidate cache. Nothing helps. I also tried to use compile instead of implementation. I also tried different versions of both libraries, also without success.

Answer

Aks4125 picture Aks4125 · Nov 15, 2017

It will give error because official release for rxjava is 2.1.5.

simply change below lines of code

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

Official documentation