1.1.1
1.3.20
Client Multiplatform Android/iOS
Hi
I'm having an issue to build a library shared between Android and iOS. The Android versions work fine, but when I try to create the artifact for Xcode I have the following error:
> Task :common:compileKotlinIos
warning: skipping /Users/max.cruz/.gradle/caches/modules-2/files-2.1/io.ktor/ktor-client-ios-iosx64/1.1.1/4daba45a7325f8902d9ae7fa1fa6ad15867ef749/ktor-client-ios.klib. The abi versions don't match. Expected '[5]', found '2'
warning: the compiler versions don't match either. Expected '[1.1.1]', found '1.0.3-release-5085'
error: compilation failed: Could not find "/Users/max.cruz/.gradle/caches/modules-2/files-2.1/io.ktor/ktor-client-ios-iosx64/1.1.1/4daba45a7325f8902d9ae7fa1fa6ad15867ef749/ktor-client-ios.klib" in [/Users/max.cruz/IdeaProjects/TpagaApp/common, /Users/max.cruz/.konan/klib, /Users/max.cruz/.konan/kotlin-native-macos-1.1.1/klib/common, /Users/max.cruz/.konan/kotlin-native-macos-1.1.1/klib/platform/ios_x64].
Hi @maxcruz, thanks for the report.
Could you reproduce the problem with 1.1.2 and provide dependencies section from build.gradle?
Hi @e5l thanks to you for your help.
Dependencies for the version 1.1.2 aren't in my repository. Which should I use?
Here are my Gradle files:
gradle.properties
# kotlin
kotlin.code.style=official
kotlin.incremental.multiplatform = true
# kotlin libraries
kotlin_version=1.3.20
coroutines_version=1.1.0
ktor_version=1.1.1
serialization_version=0.9.1
android_plugin_version=3.2.0
build.gradle (project level)
buildscript {
repositories {
maven { url "http://kotlin.bintray.com/kotlin-eap" }
maven { url "http://kotlin.bintray.com/kotlin-dev" }
maven { url "https://kotlin.bintray.com/kotlinx" }
maven { url 'https://dl.bintray.com/jetbrains/kotlin-native-dependencies' }
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:$android_plugin_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
}
}
allprojects {
repositories {
maven { url "https://kotlin.bintray.com/kotlinx" }
maven { url "http://kotlin.bintray.com/kotlin-eap" }
maven { url "http://kotlin.bintray.com/kotlin-dev" }
maven { url "https://dl.bintray.com/kotlin/ktor" }
google()
jcenter()
}
}
build.gradle (common module)
apply plugin: 'kotlin-multiplatform'
apply plugin: 'kotlinx-serialization'
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
}
release {
}
}
sourceSets {
main {
manifest.srcFile 'src/androidMain/AndroidManifest.xml'
java.srcDirs = ['src/androidMain/kotlin']
res.srcDirs = ['src/androidMain/res']
}
test {
java.srcDirs = ['src/androidTest/kotlin']
res.srcDirs = ['src/androidTest/res']
}
}
}
dependencies {
implementation "com.segment.analytics.android:analytics:4.3.1"
implementation "com.android.support:multidex:1.0.3"
}
kotlin {
targets {
fromPreset(presets.android, 'android')
final def iOSTarget = System.getenv('SDK_NAME')?.startsWith("iphoneos") ? presets.iosArm64 : presets.iosX64
fromPreset(iOSTarget, 'ios') {
compilations.main.outputKinds('FRAMEWORK')
}
}
sourceSets {
commonMain {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serialization_version"
implementation "io.ktor:ktor-client-core:$ktor_version"
implementation "io.ktor:ktor-client-json:$ktor_version"
implementation "io.ktor:ktor-client-logging:$ktor_version"
}
}
commonTest {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-test-common"
implementation "org.jetbrains.kotlin:kotlin-test-annotations-common"
}
}
androidMain {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serialization_version"
implementation "io.ktor:ktor-client-core-jvm:$ktor_version"
implementation "io.ktor:ktor-client-json-jvm:$ktor_version"
implementation "io.ktor:ktor-client-logging-jvm:$ktor_version"
implementation "io.ktor:ktor-client-okhttp:$ktor_version"
}
}
androidTest {
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-test'
implementation 'org.jetbrains.kotlin:kotlin-test-junit'
}
}
iosMain {
dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$serialization_version"
implementation "io.ktor:ktor-client-ios:$ktor_version"
implementation "io.ktor:ktor-client-core-native:$ktor_version"
implementation "io.ktor:ktor-client-json-native:$ktor_version"
implementation "io.ktor:ktor-client-logging-native:$ktor_version"
}
}
}
}
Update: To update to Ktor 1.1.2 it's necessary also upgrade Gradle to 4.10.X (4.10.3 in my case)
Apparently, related the problem is fixed with this update, but now I have a new one with the serializer.
Can't locate polymorphic serializer definition
Let try to investigate to fix that another issue to confirm if the update resolves the previous problem. Thanks
I can confirm that this problem is solved using Ktor 1.1.2, Kotlin 1.3.20 and Gradle 4.10.3
To fix the serializer issue I removed the @Serializable annotation from classes in the common module and provided the KSerializer interface separated.
Everything is working as is expected now. Thanks for your help.
I have the same issue on the latest release of Kotlin. Could you help with problem?
w: The compiler versions don't match either. Expected '[1.2]', found '1.1.2-release-6625'
# kotlin
kotlin_version=1.3.30
kotlin.incremental.multiplatform = true
# kotlin libraries
coroutines_version=1.1.1
ktor_version=1.1.2
serialization_version=0.10.0
# android
gradle_android_version=3.3.2
The ktor-client-ios 1.1.2 is not compatible with 1.3.30.
i have ktor-client-ios 1.1.3 and i also have this error message when i try upgrading kotlin to 1.3.30. Is there a ktor version that supports kotlin 1.3.30?
I was able to make it work by updating ktor lib to 1.1.4
Most helpful comment
I was able to make it work by updating ktor lib to 1.1.4