Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to resolve: androidx.lifecycle:lifecycle-extensions-ktx:2.0.0-alpha1

I am trying to understand ViewModel and LiveData concepts in android. I am making a practice project but when i added implementation 'androidx.lifecycle:lifecycle-extensions-ktx:2.0.0-alpha1' line in my app level gradle file it shows me

Failed to resolve: androidx.lifecycle:lifecycle-extensions-ktx:2.0.0-alpha1.

I have searched on google for solution and i found this answer, it works when i compile only viewmodel library but if i compile extensions library using same method as implementation group: 'androidx.lifecycle', name:'lifecycle-extensions-ktx', version: '2.0.0-alpha1', it shows the same error as above. I have also tried to find it on Maven repositories site here but i didn't have any information for how to compile it.

UPDATE

App Level Build.gradle

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

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

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation group: 'androidx.lifecycle', name:'lifecycle-extensions-ktx', version: '2.0.0-alpha1'
    implementation group: 'androidx.lifecycle', name:'lifecycle-viewmodel-ktx', version: '2.0.0-alpha1'
}
like image 830
Jaydip Kalkani Avatar asked Jun 17 '18 04:06

Jaydip Kalkani


1 Answers

UPDATE

As per @Dr.jacky's comment and Android Developers Documentation,

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

More Info at https://developer.android.com/jetpack/androidx/releases/lifecycle


I have found the answer. As Thunder Knight said here it seems to be that the repository was emptied somehow. Hence, you can not download it from the repository.. I agree with this and so i was looking for answer on mvnrepository.com and i found it here. I have to add

implementation group: 'androidx.lifecycle', name: 'lifecycle-extensions', version: '2.0.0-alpha1'

line for adding lifecycle-extensions and also i was adding -ktx in name of library but it was the mistake. In documentation they have not commented to add -ktx in line of lifecycle-extensions.

Credits:- @Thunder Knight

like image 200
Jaydip Kalkani Avatar answered Sep 19 '22 22:09

Jaydip Kalkani