Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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 too enter 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'
                Try add these plugins {     id 'com.android.application'     id 'kotlin-android'     id 'kotlin-kapt' }
– Ticherhaz FreePalestine
                Jul 4, 2021 at 8:29

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"
                ive tried with 1.1.1 and it worked, thanks for that, but can you help me understand why it didnt work and do you see any thing which is wrong in my build.gradle
– Gaurav Roy
                Jul 4, 2021 at 10:01
                @GauravRoy, you use def room_version = "2.2.6" and implementation "android.arch.lifecycle:extensions:$room_version", but this library doesn't exist in 2.2.6 version, only 1.1.1 or less.
– CoolMind
                Jul 4, 2021 at 13:48
                I thought you used AndroidX, so was wondered how could you mix AndroidX and Pre-AndroidX libraries.
– CoolMind
                Jul 4, 2021 at 13:49

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

i checked on the repository that the library is from and as far as i can see i dont see any errors – Brandon Jul 4, 2021 at 12:24

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.