Gaurav Roy
Gaurav Roy

Reputation: 12235

Failed to resolve: android.arch.lifecycle:extensions:2.2.5

New into native android, getting a weird issue while building for first time on my formatted windows machine. Ive developed the code on Mac, and it runs smoothly.

Error is and hence it fails while building tooenter image description here

Failed to resolve: android.arch.lifecycle:extensions:2.2.5

any idea on what can be the error?

my app gradle is

plugins {
    id 'com.android.application'
}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.unique.dailyreminder"
        minSdkVersion 24
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    def room_version = "2.2.6"

    def lottieVersion = "3.7.0"
    def lifecycle_version = "2.3.1"
    implementation "com.airbnb.android:lottie:$lottieVersion"

    implementation "androidx.room:room-runtime:$room_version"
    annotationProcessor "androidx.room:room-compiler:$room_version"
    // Lifecycle components
    implementation "android.arch.lifecycle:extensions:$room_version"
    annotationProcessor "android.arch.lifecycle:compiler:$room_version"

    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'

}

Upvotes: 1

Views: 3697

Answers (2)

Brandon
Brandon

Reputation: 156

If you go on Google's maven Repository and you look for the library in question you notice that the latest version of the library you are trying to use that's available is 1.1.1 while the one in your build.gradle is 2.2.6 so try changing it to 1.1.1 like so change "room_verson" to "1.1.1" like so:

plugins {
    id 'com.android.application'
}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.unique.dailyreminder"
        minSdkVersion 24
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android- 
            optimize.txt'), 
            'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    def room_version = "1.1.1"

    def lottieVersion = "3.7.0"
    def lifecycle_version = "2.3.1"
    implementation "com.airbnb.android:lottie:$lottieVersion"

    implementation "androidx.room:room-runtime:$room_version"
    annotationProcessor "androidx.room:room-compiler:$room_version"
    // Lifecycle components
    implementation "android.arch.lifecycle:extensions:$room_version"
    annotationProcessor "android.arch.lifecycle:compiler:$room_version"

    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'

}

link to library: https://maven.google.com/web/index.html?q=lifecycle#android.arch.lifecycle:extensions:1.1.1

Upvotes: 1

CoolMind
CoolMind

Reputation: 28875

See https://developer.android.com/jetpack/androidx/releases/lifecycle.

The APIs in lifecycle-extensions have been deprecated. Instead, add dependencies for the specific Lifecycle artifacts you need.

dependencies {
    def lifecycle_version = "2.4.0-alpha02"
    def arch_version = "2.1.0"

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

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

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

Pre-AndroidX Versions (which is wrong for your project):

dependencies {
    def lifecycle_version = "1.1.1"

    // ViewModel and LiveData
    implementation "android.arch.lifecycle:extensions:$lifecycle_version"

Upvotes: 2

Related Questions