Build failed - Could not find androidx.lifecycle:compiler:2.2.0

Viewed 1327

I am totally new to Android and struggling past 2days with my build. I get the following message

Build failed
Could not find androidx.lifecycle:compiler:2.2.0.
Searched in the following locations:
  - https://dl.google.com/dl/android/maven2/androidx/lifecycle/compiler/2.2.0/compiler-2.2.0.pom
  - https://jcenter.bintray.com/androidx/lifecycle/compiler/2.2.0/compiler-2.2.0.pom
Required by:   project :app

I updated my studio and gradle plugins and versions of dependencies, but none seem to work. I am using Gradle Plugin: 4.0.1 and Gradle: 6.1.1 My project gradle is as follows

buildscript {
    
    repositories {
        google()
        maven { url 'https://maven.google.com' }
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.1'          
    }
}
allprojects {
    repositories {
        google()
        jcenter()
    }
}

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

And my app gradle is as follows

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.xxxx.xxxxxx"
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'com.google.android.material:material:1.2.0-alpha04'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'androidx.appcompat:appcompat:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'

    def room_version = "2.2.0"
    def lifecycle_version = "2.2.0"

    implementation "androidx.room:room-runtime:$room_version"
    annotationProcessor "androidx.room:room-compiler:$room_version"

    // ViewModel
    implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version"
    // LiveData
    implementation "androidx.lifecycle:lifecycle-livedata:$lifecycle_version"
    // Lifecycles only (without ViewModel or LiveData)
    implementation "androidx.lifecycle:lifecycle-runtime:$lifecycle_version"

    // Saved state module for ViewModel
    implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version"

    // Annotation processor
    annotationProcessor "androidx.lifecycle:compiler:$lifecycle_version"
    // alternately - if using Java8, use the following instead of lifecycle-compiler
    implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"

    // optional - RxJava support for Room
    implementation "androidx.room:room-rxjava2:$room_version"

    // Test helpers
    testImplementation "androidx.room:room-testing:$room_version"
}

In the idea.log i find the line

testKnownPluginVersionProvider - 'gradle' plugin missing from the offline Maven repo, will use default 4.0.1 

repeating regularly and the gradle-wrapper properties file is as follows

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
1 Answers

Remove the following line if you are using Java 8:

annotationProcessor "androidx.lifecycle:compiler:$lifecycle_version"
Related