Home > other >  Cannot be solved: androidx. Lifecycle: lifecycle - extensions - KTX: 2.0.0-1
Cannot be solved: androidx. Lifecycle: lifecycle - extensions - KTX: 2.0.0-1

Time:10-01

I try to understand the ViewModel in android and LiveData concept. I'm doing a practice project but when I was in my application level gradle file to add 'androidx. Lifecycle: lifecycle - extensions - KTX: 2.0.0-1', it shows I


Failed to resolve:
Androidx. Lifecycle: lifecycle - extensions - KTX: 2.0.0-1.

I search on Google solution, I found the answer to this, when I compile the viewmodel library but if I only use and implementation of compiler extensions library, set the same way it works: 'androidx. Lifecycle, name:' lifecycle - extensions - KTX, 'version:' 2.0.0-1 ', it shows the same as the above mistakes. I also try to find it in the Maven repository site here, but I don't have any information on how to compile it.
The UPDATE
App Level Build. Gradle

Apply the plugin: '. Com. Android application '

Apply the plugin: 'kotlin - android'

Apply the plugin: 'kotlin - android - extensions'

Android {
CompileSdkVersion 28
DefaultConfig {
ApplicationId "* * * * * * * * * * * * * * *"
MinSdkVersion 19
TargetSdkVersion 28
VersionCode 1
VersionName "1.0"
TestInstrumentationRunner "android. Support. The test. The 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. The constraint, the 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-1
Implementation group: 'androidx. Lifecycle, name:' lifecycle - viewmodel - KTX, version: '2.0.0-1
}

CodePudding user response:

I found the answer. Just like the thunder knight put it, seems to be a repository to some extent be emptied. Therefore, you can not download from the repository.. I agree with that, so I at mvnrepository.com to find the answer, I find it here. I have to add


Implementation group: 'androidx. Lifecycle, name:' lifecycle - extensions, version: '2.0.0-1
'
Add life cycle extension line, I also added in the library - KTX, but this is wrong. In the documentation, they didn't comment is added in the life cycle extension - KTX.
Thanks: - @ Thunder Knight

CodePudding user response:

Big brother, you can not use translate machine of Chinese?
It is not as good as English directly the original
  • Related