我正在尝试为Android使用新的导航架构组件,我收到错误 无法解决:androidx.lifecycle:lifecycle-viewmodel-ktx:1.1.1 当我将lifecycle_version定义为“1.1.1”
时我基本上只是复制和粘贴文档中的内容,所以我在这里找不到有问题的想法:(
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.mobile.codgin.newnavigation"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
def lifecycle_version = "1.1.1"
// ViewModel and LiveData
implementation "android.arch.lifecycle:extensions:$lifecycle_version"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
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'
}
答案 0 :(得分:13)
尝试替换
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
用这个
//https://mvnrepository.com/artifact/androidx.lifecycle/lifecycle-viewmodel-ktx
implementation group: 'androidx.lifecycle', name:'lifecycle-viewmodel-ktx', version: '2.0.0-alpha1'
然后再次同步。
你可以看看这里: https://mvnrepository.com/artifact/androidx.lifecycle/lifecycle-viewmodel-ktx/2.0.0-alpha1
似乎存储库以某种方式被清空了。因此,您无法从存储库下载它。