在運行我的應用程式時,我收到此錯誤(以及其他 6 個類似錯誤),將代碼中的房間版本更改為 2.3.0 或 2.2.3 并不能解決問題。
1:任務因例外而失敗。
- 出了什么問題:任務“:app:checkDebugAarMetadata”的執行失敗。
無法決議配置“:app:debugRuntimeClasspath”的所有檔案。找不到 androidx.room:room-coroutines:2.4.0。在以下位置搜索: - https://dl.google.com/dl/android/maven2/androidx/room/room-coroutines/2.4.0/room-coroutines-2.4.0.pom - https://repo .maven.apache.org/maven2/androidx/room/room-coroutines/2.4.0/room-coroutines-2.4.0.pom - https://jcenter.bintray.com/androidx/room/room-coroutines/2.4 .0/room-coroutines-2.4.0.pom 需要:專案:app
- 嘗試:
使用 --stacktrace 選項運行以獲取堆疊跟蹤。使用 --info 或 --debug 選項運行以獲得更多日志輸出。使用 --scan 運行以獲得完整的見解。
這是我的專案 Build.Gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.5.31'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
ext {
activityVersion = '1.4.0'
appCompatVersion = '1.4.0'
constraintLayoutVersion = '2.1.2'
coreTestingVersion = '2.1.0'
coroutines = '1.5.2'
lifecycleVersion = '2.4.0'
materialVersion = '1.4.0'
roomVersion = '2.4.0'
// testing
junitVersion = '4.13.2'
espressoVersion = '3.4.0'
androidxJunitVersion = '1.1.3'
}
task clean(type: Delete) {
delete rootProject.buildDir
}
這是我的應用程式 Build.Gradle:
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.example.burnouttracker"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
packagingOptions {
exclude 'META-INF/atomicfu.kotlin_module'
}
kotlinOptions {
jvmTarget = "1.8"
}
}
dependencies {
implementation "androidx.appcompat:appcompat:$rootProject.appCompatVersion"
implementation "androidx.activity:activity-ktx:$rootProject.activityVersion"
// Dependencies for working with Architecture components
// You'll probably have to update the version numbers in build.gradle (Project)
// Room components
//implementation "androidx.room:room-ktx:$rootProject.roomVersion"
implementation("androidx.room:room-runtime:$rootProject.roomVersion")
kapt "androidx.room:room-compiler:$rootProject.roomVersion"
androidTestImplementation "androidx.room:room-testing:$rootProject.roomVersion"
//I added this one
implementation "androidx.room:room-coroutines:$rootProject.roomVersion"
// Lifecycle components
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$rootProject.lifecycleVersion"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$rootProject.lifecycleVersion"
implementation "androidx.lifecycle:lifecycle-common-java8:$rootProject.lifecycleVersion"
// Kotlin components
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$rootProject.coroutines"
api "org.jetbrains.kotlinx:kotlinx-coroutines-android:$rootProject.coroutines"
// UI
implementation "androidx.constraintlayout:constraintlayout:$rootProject.constraintLayoutVersion"
implementation "com.google.android.material:material:$rootProject.materialVersion"
// Testing
testImplementation "junit:junit:$rootProject.junitVersion"
androidTestImplementation "androidx.arch.core:core-testing:$rootProject.coreTestingVersion"
androidTestImplementation ("androidx.test.espresso:espresso-core:$rootProject.espressoVersion", {
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestImplementation "androidx.test.ext:junit:$rootProject.androidxJunitVersion"
//implementation 'androidx.core:core-ktx:1.7.0'
//implementation 'androidx.appcompat:appcompat:1.4.0'
//implementation 'com.google.android.material:material:1.4.0'
//implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
//testImplementation 'junit:junit:'
//androidTestImplementation 'androidx.test.ext:junit:1.1.3'
//androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
uj5u.com熱心網友回復:
我看到你評論room-ktx并添加了room-coroutine
從房間版本 2.1.0-alpha05 開始,工件room-coroutines已被重room-ktx命名為遵循與其他 androidx 工件相同的命名。
所以請使用room-ktx代替room-coroutines
//...
//room dependencies
implementation "androidx.room:room-ktx:$$rootProject.roomVersion"
implementation "androidx.room:room-runtime:$$rootProject.roomVersion"
kapt "androidx.room:room-compiler:$$rootProject.roomVersion"
androidTestImplementation "androidx.room:room-testing:$rootProject.roomVersion"
//...
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/398936.html
標籤:安卓工作室 科特林 android-room
上一篇:如何在控制臺中列印插入的值?(顫振|sqflite)
下一篇:文本在不同模擬器上的大小不同
