android - KMM : How to resolve Incompatible abi version. 当前默认为 '1.4.2' ,找到 '1.5.0' 。 1.5.20编译器产生的库?

标签 android gradle kotlin-multiplatform ktor kotlin-multiplatform-mobile

我正在制作 KMM application ,我已经完成了Android部分,没有任何问题,一切正常。
尽管如此,当我启动 iOS 版本时,通过打开 iosMyApp.xcworkspace文件,然后我启动编译,出现此错误。

The following Kotlin source sets were configured but not added to any Kotlin compilation:
 * androidAndroidTestRelease
 * androidTestFixtures
 * androidTestFixturesDebug
 * androidTestFixturesRelease
You can add a source set to a target's compilation by connecting it with the compilation's default source set using 'dependsOn'.
See https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#connecting-source-sets
w: skipping /Users/jeremieguillot/.gradle/caches/modules-2/files-2.1/io.ktor/ktor-client-serialization-iosx64/1.6.3/1912839739c3051183691e878ef7e4d17366f4f4/ktor-client-serialization.klib. **Incompatible abi version. The current default is '1.4.2', found '1.5.0'. The library produced by 1.5.20 compiler**
e: Could not find "/Users/jeremieguillot/.gradle/caches/modules-2/files-2.1/io.ktor/ktor-client-serialization-iosx64/1.6.3/1912839739c3051183691e878ef7e4d17366f4f4/ktor-client-serialization.klib" in [/Users/jeremieguillot/AndroidStudioProjects/SpotABivouac/iosSpotApp/Pods, /Users/jeremieguillot/.konan/klib, /Users/jeremieguillot/.konan/kotlin-native-prebuilt-macos-1.5.10/klib/common, /Users/jeremieguillot/.konan/kotlin-native-prebuilt-macos-1.5.10/klib/platform/ios_x64]
Daemon vm is shutting down... The daemon has exited normally or was terminated in response to a user interrupt.
----- End of the daemon log -----


FAILURE: Build failed with an exception.

* What went wrong:
Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org
> **Task :shared:compileKotlinIos**
**Command PhaseScriptExecution failed with a nonzero exit code**
目前,我在 iOS 部分没有任何内容。
这是我的项目的配置。
build.gradle.kts (:shared)
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget

plugins {
    kotlin("multiplatform")
    kotlin("native.cocoapods")
    id("com.android.library")
    kotlin("plugin.serialization") version "1.5.10"
}

version = "1.0"

kotlin {
    android()

    val iosTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget =
        if (System.getenv("SDK_NAME")?.startsWith("iphoneos") == true)
            ::iosArm64
        else
            ::iosX64

    iosTarget("ios") {}

    cocoapods {
        summary = "Some description for the Shared Module"
        homepage = "Link to the Shared Module homepage"
        ios.deploymentTarget = "15.0"
        frameworkName = "shared"
        podfile = project.file("../iosSpotApp/Podfile")
    }

    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2")
                implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.2.1")
                implementation("io.ktor:ktor-client-core:1.6.3")
                implementation("io.ktor:ktor-client-serialization:1.6.3")
                implementation("com.russhwolf:multiplatform-settings-no-arg:0.7.7")
            }
        }

        val commonTest by getting {
            dependencies {
                implementation(kotlin("test-common"))
                implementation(kotlin("test-annotations-common"))
            }
        }
        val androidMain by getting {
            dependencies {
                implementation("io.ktor:ktor-client-android:1.6.3")
            }
        }

        val androidTest by getting {
            dependencies {
                implementation(kotlin("test-junit"))
                implementation("junit:junit:4.13.2")
            }
        }
        val iosMain by getting {
            dependencies {
                implementation("io.ktor:ktor-client-ios:1.6.3")
            }
        }
        val iosTest by getting
    }
}

android {
    compileSdk = 31
    sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
    defaultConfig {
        minSdk = 23
        targetSdk = 31
    }
}
构建.gradle.kts
buildscript {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:7.1.0-alpha12")
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10")
        classpath("com.apollographql.apollo:apollo-gradle-plugin:2.5.9")
        classpath("com.google.dagger:hilt-android-gradle-plugin:2.38.1")
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        maven("https://jitpack.io")
    }
}

tasks.register("clean", Delete::class) {
    delete(rootProject.buildDir)
}
我尝试将此行修改为旧版本,但没有成功。
implementation("io.ktor:ktor-client-ios:1.6.3")
有没有人有解决方案或有什么需要调查的? 😊

最佳答案

我能够通过将 Kotlin 从 1.5.10 更新到 1.5.20 来解决这个问题。

关于android - KMM : How to resolve Incompatible abi version. 当前默认为 '1.4.2' ,找到 '1.5.0' 。 1.5.20编译器产生的库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69318883/

相关文章:

java - 如何在不安装的情况下从一个应用程序启动另一个应用程序

android - Mac OS 的 OpenJDK 8 不可用

maven - 我的共享(Gradle)库没有被正确读取...Artifactory Maven Pom 文件未发布排除项可能是原因

gradle - 从 ktor 服务 kotlin 多平台 javascript

unit-testing - Kotlin Multiplatform Gradle 单元测试无法解析 kotlin.test 引用

gradle - 在多平台 js 和 jvm 项目中使用 kotlin-dce-js

android - 在 SplashActivity 中显示的 Firebase 应用内消息。如何在 MainActivity 中显示它?

java - android按钮不断生成字符串

java - Gradle (java) : test task should use generated . jar 而不是类路径中的 .class 文件

java - 如何通过 gradle 插件强制执行此模式?