无法解析:androidx.lifecycle :lifecycle-viewmodel-ktx:1.1.1



我正在尝试使用适用于 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'
}

尝试替换

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

似乎存储库以某种方式被清空了。因此,您无法从存储库下载它。

当它显示此错误时,请将此代码添加到第build.gradle

configurations {
all {
exclude group: 'androidx.lifecycle', module: 'lifecycle-viewmodel-ktx'
}
}

相关内容

  • 没有找到相关文章

最新更新