11

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.

Alexander Tumanin
  • 1,638
  • 2
  • 23
  • 37
  • 3
    Are you running gradle in offline mode? – laalto Nov 14 '17 at 14:24
  • No, I also use `androidAnnotations` in the app, just skipped the dependencies to make the snippet shorter. They can't compile offline at all. – Alexander Tumanin Nov 14 '17 at 14:27
  • 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.) – laalto Nov 14 '17 at 14:29
  • Yes, I mean this too. I build online – Alexander Tumanin Nov 14 '17 at 14:31
  • 1
    In https://github.com/ReactiveX/RxAndroid they said the latest version of rxJava for rxAndroid is only `2.1.5` – nhoxbypass Nov 15 '17 at 15:15
  • 1
    But in the [repository](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22io.reactivex.rxjava2%22%20a%3A%22rxjava%22) (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 helping – Alexander Tumanin Nov 15 '17 at 15:38
  • @laalto you saved my day. It is bizzare though, when it cant find it locally it should try to get it from the repos. – dsharew Dec 13 '17 at 15:23

5 Answers5

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

Aks4125
  • 4,522
  • 4
  • 32
  • 48
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.

Alexander Tumanin
  • 1,638
  • 2
  • 23
  • 37
  • 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. – Aks4125 Nov 15 '17 at 09:54
  • **Could not HEAD 'http://jcenter.bintray.com/org/jacoco/org.jacoco.report/0.7.4.201502262128/org.jacoco.report-0.7.4.201502262128.jar'** – IgorGanapolsky Feb 26 '18 at 22:45
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

Sid
  • 141
  • 1
  • 5
  • 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! – Meenohara Jan 07 '21 at 11:27
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/"
    }
   }
}
Ashif
  • 441
  • 5
  • 12
-1

Just try to uncheck the offline mode in your

Settings -> Gradle

and try again.That's worked for me

venu46
  • 419
  • 5
  • 10
  • in offline mode you will not be able to resolve all dependencies, not only particular one or two – Alexander Tumanin Aug 30 '18 at 11:17
  • Uncheck means build your gradle in online mode – venu46 Aug 30 '18 at 12:19
  • 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. – Alexander Tumanin Aug 30 '18 at 12:55