无法解析 Kotlin 库 io.ktor-ktor-client-logging
Failed to resolve Kotlin library 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.properties 中设置 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 版本。查看 Recommended kotlinx library versions 了解详细信息。可能,您需要将 Kotlin 更改为 1.5.30,或者将 Ktor 降级到 1.5.4。
请在下方评论结果。如果仍然有问题,我会更新这个答案。
我正在尝试为 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.properties 中设置 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 版本。查看 Recommended kotlinx library versions 了解详细信息。可能,您需要将 Kotlin 更改为 1.5.30,或者将 Ktor 降级到 1.5.4。
请在下方评论结果。如果仍然有问题,我会更新这个答案。