无法解析 com.squareup.sqldelight:native-driver:1.3.0

Could not resolve com.squareup.sqldelight:native-driver:1.3.0

我正在尝试构建一个 Kotlin 多平台项目作为 iOS 和 Android 应用程序的共享模块。我正在尝试集成 SQLDelight,但在同步 Gradle 时遇到此错误。下面分别是报错和build.gradle文件

错误

Could not resolve com.squareup.sqldelight:native-driver:1.3.0. Required by: project :

Possible solution: - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

build.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
}

我删除了

implementation "com.squareup.sqldelight:native-driver:1.3.0" 来自 commonMaindependecies

成功了。

工作build.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"
            }
        }
        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
}