Cannot resolve rxjava2 with gradle 3.0
Asked Answered
P

5

12

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.

Plenish answered 14/11, 2017 at 14:22 Comment(7)
Are you running gradle in offline mode?Clearcole
No, I also use androidAnnotations in the app, just skipped the dependencies to make the snippet shorter. They can't compile offline at all.Plenish
I mean the Android Studio Gradle "Offline work" checkbox in app settings, not actually being offline. (Or some other method that sets --offline on gradle invocation.)Clearcole
Yes, I mean this too. I build onlinePlenish
In github.com/ReactiveX/RxAndroid they said the latest version of rxJava for rxAndroid is only 2.1.5Cassis
But in the repository (which link is also on github page) you can see the latest version 2.1.6. Anyways, I already answered in the comments below, that change to 2.1.5 hot helpingPlenish
@Clearcole you saved my day. It is bizzare though, when it cant find it locally it should try to get it from the repos.Explore
P
2

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.

Plenish answered 15/11, 2017 at 9:48 Comment(2)
Eventually, there wasn't any issue of rxjava library. I tried to copy your build gradle file and worked for me without any issue. I wondered why.Preserve
Could not HEAD 'jcenter.bintray.com/org/jacoco/org.jacoco.report/…'Entirety
P
4

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

Preserve answered 15/11, 2017 at 8:35 Comment(1)
Not working. Anyways, as you see in my question, io.reactivex.rxjava2:rxandroid:2.0.1 also not found. It's not a version issue.Plenish
P
2

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.

Plenish answered 15/11, 2017 at 9:48 Comment(2)
Eventually, there wasn't any issue of rxjava library. I tried to copy your build gradle file and worked for me without any issue. I wondered why.Preserve
Could not HEAD 'jcenter.bintray.com/org/jacoco/org.jacoco.report/…'Entirety
L
1

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

Liveryman answered 12/4, 2019 at 16:0 Comment(1)
I do not know how your solution is working, but I have been able to get rid of the warnings, but not much coding done yet. Given that I am referring to this almost after 2 years of your answer I tried replacing version with 3 but the warnings resurfaced. Thank you!Agbogla
V
0

@link https://github.com/ReactiveX/RxAndroid

// Because RxAndroid releases are few and far between, it is recommended you also // explicitly depend on RxJava's latest version for bug fixes and new features. // (see https://github.com/ReactiveX/RxJava/releases for latest 3.x.x version)

// Step 1 : in side build.gradle(Module:app)
 implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
// Step 2 : in side build.gradel(Project:ProjectName)  
 allprojects {
repositories {
    google()
    jcenter()
    maven { url "https://jitpack.io" }
    jcenter {
        url "http://jcenter.bintray.com/"
    }
   }
}
Vaporization answered 29/2, 2020 at 8:15 Comment(0)
I
-1

Just try to uncheck the offline mode in your

Settings -> Gradle

and try again.That's worked for me

Innocency answered 30/8, 2018 at 10:0 Comment(3)
in offline mode you will not be able to resolve all dependencies, not only particular one or twoPlenish
Uncheck means build your gradle in online modeInnocency
Uncheck means it was checked before and my gradle was in offline mode. In offline mode you will not be able to resolve all dependencies, not only particular one or two. In my question I had trouble only with two particular dependencies. And in my comment from Nov 14'17 under the question i already mentioned it.Plenish

© 2022 - 2024 — McMap. All rights reserved.