我正在尝试使用新的导航架构组件用于
Android,我收到了错误
无法解决:androidx.lifecycle:lifecycle-viewmodel-ktx:1.1.1
当我将lifecycle_version定义为“1.1.1”时
无法解决: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
它似乎是以某种方式清空了存储库.因此,您无法从存储库下载它.