我试图为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文件夹中看到了包。
当我在kotlin.mpp.enableGranularSourceSetsMetadata=false
中设置gradle.properties时,错误更改为:
> 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]
发布于 2021-09-13 08:28:14
后一个错误建议您同步正在使用的Kotlin版本和Ktor版本。有关详细信息,请查看推荐的kotlinx库版本。您可能需要将Kotlin更改为1.5.30,或将Ktor 1.5.4降级。
请与下面的结果评论。如果还会有什么问题,我会更新这个答案。
https://stackoverflow.com/questions/69151011
复制相似问题