Search code examples
androidandroid-gradle-pluginrx-androidrx-java2

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.


Solution

  • I found the solution. The issue was my proxy, it blocks https and I need to use the http version of repository. So instead of:

    repositories {
            jcenter()
        }
    

    I use now:

    repositories {
            jcenter {
                url "http://jcenter.bintray.com/"
            }
        }
    

    and it compiles now.