找不到 androidx:room:2.7.0-alpha01。在 Kotlin 多平台中

问题描述 投票:0回答:1

我已经开始了一个新的示例 KMP 项目,我要构建一个包含房间数据库的项目。 Room 版本 2.7.0-alpha01 现在支持 KMP,这里是官方文档。我已将所有依赖项添加到我的 KMP 项目中,如此处所述。但无法为 ANDROID 应用程序构建项目,IOS 工作正常。

libs.versions.toml

[libraries]
room = { module = "androidx:room", version.ref = "roomVersion" }
androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref = "roomVersion" }

[plugins]
room = { id = "androidx.room", version.ref = "roomVersion" }

build.gradle.kts

plugins{
   alias(libs.plugins.room)
}

androidMain.dependencies {
   implementation(libs.compose.ui.tooling.preview)
   implementation(libs.androidx.activity.compose)
   implementation(libs.room)
   implementation(libs.androidx.room.compiler)
}

当我单击运行按钮并且配置为

composeApp
时,我收到以下错误。

enter image description here

android android-room kotlin-multiplatform
1个回答
0
投票

您正在请求一个名为

androidx.room:2.7.0-alpha01
的依赖项 - 这不是一个有效的工件。正如 Room KMP 文档 中所解释的,您真正想要的工件是
androidx.room:room-runtime:2.7.0-alpha01
- 请注意中间的
room-runtime

这意味着您的

libs.versions.toml
应该看起来像:

room = { group = "androidx.room", name = "room-runtime", version.ref = "roomVersion" }
androidx-room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "roomVersion" }

您会注意到使用

group
name
androidx.room
第一部分与每个工件的正确名称分开。

© www.soinside.com 2019 - 2024. All rights reserved.