我正在尝试构建一个 Kotlin 多平台项目作为 iOS 和 Android 应用程序的共享模块。我正在尝试集成SQLDelight,但在同步 Gradle 时遇到了这个错误。下面分别是error和build.gradle文件。
错误
无法解析 com.squareup.sqldelight:native-driver:1.3.0。要求:项目:
可能的解决方案: - 声明提供工件的存储库,请参阅 https://docs.gradle.org/current/userguide/declaring_repositories.html上的文档
构建.gradle
buildscript {
repositories {
mavenCentral()
jcenter()
google()
}
dependencies {
classpath 'com.squareup.sqldelight:gradle-plugin:1.3.0'
}
}
plugins {
id 'org.jetbrains.kotlin.multiplatform' version '1.3.72'
id 'org.jetbrains.kotlin.plugin.serialization' version '1.3.72'
}
repositories {
mavenCentral()
jcenter()
google()
}
group 'com.example'
version '0.0.1'
apply plugin: 'com.squareup.sqldelight'
apply plugin: 'maven-publish'
def ktor_version = '1.3.2'
kotlin {
jvm()
// This is for iPhone simulator
// Switch here to iosArm64 (or iosArm32) to build library for iPhone device
iosX64("ios") {
binaries {
framework()
}
}
sourceSets {
commonMain {
dependencies {
implementation kotlin('stdlib-common')
implementation "io.ktor:ktor-client-core:$ktor_version"
implementation "io.ktor:ktor-client-serialization-native:$ktor_version"
implementation "com.squareup.sqldelight:native-driver:1.3.0"
}
}
commonTest {
dependencies {
implementation kotlin('test-common')
implementation kotlin('test-annotations-common')
}
}
jvmMain {
dependencies {
implementation kotlin('stdlib')
implementation "io.ktor:ktor-client-okhttp:$ktor_version"
implementation "io.ktor:ktor-client-serialization-jvm:$ktor_version"
implementation "com.squareup.sqldelight:sqlite-driver:1.3.0"
}
}
jvmTest {
dependencies {
implementation kotlin('test')
implementation kotlin('test-junit')
}
}
iosMain {
dependencies {
implementation "io.ktor:ktor-client-ios:$ktor_version"
implementation "io.ktor:ktor-client-serialization-native:$ktor_version"
implementation "com.squareup.sqldelight:native-driver:1.3.0"
}
}
iosTest {
}
}
}
configurations {
compileClasspath
}