gpt4 book ai didi

android - 无法解析 com.squareup.sqldelight :runtime:1. 1.3

转载 作者:太空宇宙 更新时间:2023-11-03 13:07:28 25 4
gpt4 key购买 nike

我尝试将 sqldelight 集成到我的 Android/iOS 多平台库项目中,但在同步 gradle 时我遇到了几个 Unresolved 依赖项错误。

ERROR: Unable to resolve dependency for ':SharedCode@debug/compileClasspath': Could not resolve com.squareup.sqldelight:runtime:1.1.3.

ERROR: Unable to resolve dependency for ':SharedCode@debug/compileClasspath': Could not resolve com.squareup.sqldelight:runtime-jvm:1.1.3.

ERROR: Unable to resolve dependency for ':SharedCode@release/compileClasspath': Could not resolve com.squareup.sqldelight:runtime:1.1.3. ERROR: Unable to resolve dependency for ':SharedCode@release/compileClasspath': Could not resolve com.squareup.sqldelight:runtime-jvm:1.1.3.**

  • Gradle 版本 5.1.1

  • Gradle 插件 3.4.0

  • sqldelight 1.1.3

enableFeaturePreview('GRADLE_METADATA') 存在于我的 settings.gradle 中

我的项目 gradle 文件如下所示:

buildscript {
ext {
kotlin_version = '1.3.31'
ktor_version = '1.2.1'
ktor_json_version = '1.2.1'
kotlinx_coroutines_version = '1.2.1'
serialization_version = '0.11.0'
sqldelight_version = '1.1.3'
dokka_version = '0.9.16'
}

repositories {
google()
jcenter()
mavenCentral()
gradlePluginPortal()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:$dokka_version"
classpath "com.squareup.sqldelight:gradle-plugin:$sqldelight_version"
}
}

allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://kotlin.bintray.com/kotlinx" }
}
}

task clean(type: Delete) {
setDelete rootProject.buildDir
}

我的 SharedCode 库 gradle 文件:

apply plugin: 'kotlinx-serialization'
apply plugin: 'com.android.library'
apply plugin: 'org.jetbrains.kotlin.multiplatform'
apply plugin: 'com.squareup.sqldelight'

group = 'com.example.multiplatform'
version = '1.0'

android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 15
}
buildTypes {
release {
minifyEnabled false
}
}
}

dependencies {
// Specify Kotlin/JVM stdlib dependency.
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7'
implementation "com.squareup.sqldelight:runtime:1.1.3"

testImplementation 'junit:junit:4.12'
testImplementation 'org.jetbrains.kotlin:kotlin-test'
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'

androidTestImplementation 'junit:junit:4.12'
androidTestImplementation 'org.jetbrains.kotlin:kotlin-test'
androidTestImplementation 'org.jetbrains.kotlin:kotlin-test-junit'

androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

kotlin {
targets {
final def iOSTarget = System.getenv('SDK_NAME')?.startsWith("iphoneos") \
? presets.iosArm64 : presets.iosX64

fromPreset(iOSTarget, 'ios') {
binaries {
framework('SharedCode')
}
}

fromPreset(presets.android, 'androidLib')
}

sourceSets {
commonMain {
dependencies {
//HTTP
implementation "io.ktor:ktor-client-json:$ktor_json_version"
implementation "io.ktor:ktor-client-serialization:$ktor_version"
//Coroutines
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$kotlinx_coroutines_version"
//Kotlinx serialization
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serialization_version"
//sqldelight
implementation "com.squareup.sqldelight:runtime:$sqldelight_version"
}
}

androidLibMain {
dependencies {
//HTTP
implementation "io.ktor:ktor-client-json-jvm:$ktor_json_version"
implementation "io.ktor:ktor-client-serialization-jvm:$ktor_version"
//Coroutines
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinx_coroutines_version"
//Kotlinx serialization
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serialization_version"
//sqldelight
implementation "com.squareup.sqldelight:android-driver:$sqldelight_version"
}
}

iosMain {
dependencies {
//HTTP
implementation "io.ktor:ktor-client-ios:$ktor_version"
implementation "io.ktor:ktor-client-json-native:$ktor_json_version"
implementation "io.ktor:ktor-client-serialization-native:$ktor_version"
//Coroutines
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:$kotlinx_coroutines_version"
//kotlinx serialization
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$serialization_version"
//sqldelight
implementation "com.squareup.sqldelight:ios-driver:$sqldelight_version"
}
}
}
}

sqldelight {
MyApp {
packageName = 'com.example.multiplatform'
}
}

configurations {
compileClasspath
}

task packForXCode(type: Sync) {
final File frameworkDir = new File(buildDir, "xcode-frameworks")
final String mode = project.findProperty("XCODE_CONFIGURATION")?.toUpperCase() ?: 'DEBUG'
final def framework = kotlin.targets.ios.binaries.getFramework("SharedCode", mode)

inputs.property "mode", mode
dependsOn framework.linkTask

from { framework.outputFile.parentFile }
into frameworkDir

doLast {
new File(frameworkDir, 'gradlew').with {
text = "#!/bin/bash\nexport 'JAVA_HOME=${System.getProperty("java.home")}'\ncd '${rootProject.rootDir}'\n./gradlew \$@\n"
setExecutable(true)
}
}
}
tasks.build.dependsOn packForXCode

最佳答案

我解决了这个问题。第一:对所有项目应用sqldelight插件权限:

apply plugin: 'com.squareup.sqldelight'
sqldelight {
MyDatabase {
packageName = "ru.trendagent.database"
sourceFolders = ["sqldelight"]
}
}

在android部分添加:

packagingOptions {
...
exclude 'META-INF/*.kotlin_module'
}

CommonMain 部分删除 sqldelight 的所有实现将实现添加到 AndroidMain 部分:

implementation "com.squareup.sqldelight:android-driver:1.1.3" //DataBase

如果需要,将实现添加到 iosMain 部分:

implementation "com.squareup.sqldelight:ios-driver:1.1.3"//DataBase

将元数据设置添加到 gradle 到 settings.gradle 文件中:

enableFeaturePreview("GRADLE_METADATA") // IMPORTANT!

完全清理 gradle 文件,重置 gradle wrapper 和其他。不要使用 Kotlin 1.4.0。不支持sqldelight 1.1.3版本将 gradle 更改为最新版本。您可以手动下载最新的 gradle 并在 IDE 上进行设置。你需要 gradle 5.3.1 或最新版本(5.1.1 不受支持)

如果错误仍然存​​在 - 将 IDE 更改为 intellij idea 社区版

关于android - 无法解析 com.squareup.sqldelight :runtime:1. 1.3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56578726/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com