Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot resolve rxjava2 with gradle 3.0

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.

like image 769
Alexander Tumanin Avatar asked Nov 14 '17 14:11

Alexander Tumanin


2 Answers

Changing

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

to

api 'io.reactivex.rxjava2:rxjava:2.x.x'
api 'io.reactivex.rxjava2:rxandroid:2.0.1'

worked for me

like image 190
Sid Avatar answered Oct 28 '22 16:10

Sid


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

like image 24
Aks4125 Avatar answered Oct 28 '22 17:10

Aks4125