在带有 SQLDelight 的 KMM(Kotlin Multiplatform Mobile)项目中使用自定义构建类型(“快照”)时,我遇到构建错误。调试构建工作得很好,但快照构建会抛出错误:
Could not resolve all files for configuration ':android:app:snapshotRuntimeClasspath'.
Could not resolve app.cash.sqldelight:android-driver:2.0.0.
Required by:
project :android:app
project :android:app > project :kmp:shared > project :kmp:core-db
> No matching variant of app.cash.sqldelight:android-driver:2.0.0 was found.
这是我的 KMM 源集配置:
kotlin {
sourceSets {
commonMain.dependencies {
implementation(project(":kmp:core"))
implementation(project(":kmp:core-api"))
implementation(libs.sqldelight.runtime)
implementation(libs.korlibs.klock)
api(libs.sqldelight.flow.ext)
api(libs.sqldelight.primitive.adapters)
}
androidMain.dependencies {
implementation(libs.sqldelight.android.driver)
}
iosMain.dependencies {
implementation(libs.sqldelight.native.driver)
}
}
}
我已尝试以下方法,但尚未找到解决方案:
buildTypes {
getByName("snapshot"){
initWith(getByName("release"))
matchingFallbacks.addAll(listOf("debug, release"))
}
}
我认为你的
matchingFallbacks
语法是错误的。尝试将其更改为matchingFallbacks.addAll(listOf("debug", "release"))