我試圖了解android中的ViewModel和LiveData概念.我正在做一個練習專案但是當我在我的應用程式級gradle檔案中添加實作’androidx.lifecycle:lifecycle-extensions-ktx:2.0.0-alpha1’行時,它顯示了我
Failed to resolve:
androidx.lifecycle:lifecycle-extensions-ktx:2.0.0-alpha1.
我在google上搜索了解決方案,我找到了this的答案,當我只編譯viewmodel庫但是如果我使用與實作組相同的方法編譯擴展庫時,它可以作業:’androidx.lifecycle’,name:’lifecycle-extensions-ktx’,版本:’2.0.0-alpha1′,它顯示與上面相同的錯誤.我也嘗試在Maven存盤庫網站here上找到它,但我沒有任何關于如何編譯它的資訊.
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'
}
uj5u.com熱心網友回復:
我找到了答案.正如雷霆騎士所說的那樣,似乎存盤庫在某種程度上被清空了.因此,你不能從存盤庫下載..我同意這一點,所以我在mvnrepository.com尋找答案,我發現它here.我必須添加implementation group: ‘androidx.lifecycle’, name: ‘lifecycle-extensions’, version: ‘2.0.0-alpha1’
添加生命周期擴展的行,我也在庫中添加-ktx,但這是錯誤的.在documentation,他們沒有評論在生命周期擴展中添加-ktx.
致謝: – @Thunder Knight
uj5u.com熱心網友回復:
大兄弟,你可以不要用機翻的中文嗎?還不如直接貼英文的原文上來呢
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/102312.html
標籤:其他技術討論專區
上一篇:Codeforces Round #614 (Div. 2) C - NEKO's Maze Game
下一篇:PAT乙級1019
