解析Kotlin库io.ktor-ktor-client-logging失败



我正在尝试为Android和iOS编写一个简单的多平台库。我的依赖项是:

sourceSets {
val commonMain by getting {
dependencies {
implementation("io.ktor:ktor-client-core:1.6.3")
implementation("io.ktor:ktor-client-logging:1.6.3")
implementation("io.ktor:ktor-client-serialization:1.6.3")     
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.2.2")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val androidMain by getting {
dependencies {
rootProject
//implementation("com.google.android.material:material:1.4.0")
implementation("io.ktor:ktor-client-okhttp:1.6.3")
}
}
val androidTest by getting {
dependencies {
implementation("junit:junit:4.13")
}
}
val iosArm64Main by getting {
dependencies {
implementation("io.ktor:ktor-client-ios:1.6.3")
}
}
val iosArm64Test by getting
}

我得到这个错误时,构建:

java.lang.IllegalStateException: e: Failed to resolve Kotlin library: /Users/????/IdeaProjects/????/build/kotlinSourceSetMetadata/commonMain/io.ktor-ktor-client-logging/io.ktor-ktor-client-logging-commonMain.klib

即使我看到包在build/kotlinSourceSetMetaData文件夹。

当我在gradle中设置kotlin.mpp.enableGranularSourceSetsMetadata=false。属性错误变为:

> Task :compileKotlinIosArm64
w: skipping /Users/????/.gradle/caches/modules-2/files-2.1/io.ktor/ktor-client-logging-iosarm64/1.6.3/374d82df9cd22c5960ffc1eecc6ec45f3101031/ktor-client-logging.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/????/.gradle/caches/modules-2/files-2.1/io.ktor/ktor-client-logging-iosarm64/1.6.3/374d82df9cd22c5960ffc1eecc6ec45f3101031/ktor-client-logging.klib" in [/Users/????/IdeaProjects/????, /Users/????/.konan/klib, /Users/????/.konan/kotlin-native-prebuilt-macos-1.5.10/klib/common, /Users/????/.konan/kotlin-native-prebuilt-macos-1.5.10/klib/platform/ios_arm64]

后一个错误建议您同步您正在使用的Kotlin版本和Ktor版本。有关详细信息,请查看推荐的kotlinx库版本。可能,您需要将Kotlin更改为1.5.30,或者将ktlin降级为1.5.4。

请在下面评论结果。如果仍然有问题,我会更新这个答案。

最新更新