korlibs-archive / korio

Korio: Kotlin cORoutines I/O : Virtual File System + Async/Sync Streams + Async TCP Client/Server + WebSockets for Multiplatform Kotlin 1.3

Home Page:https://korlibs.soywiz.com/korio/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

kotlin 1.4 compatibility for multiplatform project

ArtRoman opened this issue · comments

Korio is seems to be compatible with kotlin 1.4, but it linked with klock 1.11.9, which is outdated and its native libraries are not compatible with new kotlin. After adding klock 1.12.0 dependency, application compiles with no error but crashes when running on Android:

java.lang.NoSuchMethodError: No virtual method fromSeconds(D)D in class Lcom/soywiz/klock/TimeSpan$Companion; or its super classes (declaration of 'com.soywiz.klock.TimeSpan$Companion' appears in /data/app/xxx-m1DsT1BYSqLFkVDXmjXnRA==/base.apk)
     at com.soywiz.korio.async.AsyncExtKt.<clinit>(AsyncExt.kt:66)
     at com.soywiz.korio.async.AsyncExtKt.asyncImmediately(Unknown Source:0)
     at com.soywiz.korio.async.AsyncThread.sync(AsyncQueue.kt:88)
     at com.soywiz.korio.async.AsyncThread.invoke(AsyncQueue.kt:75)
     at com.soywiz.korio.net.JvmAsyncClient.write(asyncSocketFactoryAndroid.kt:47)
     at com.soywiz.korio.stream.AsyncStreamKt.writeBytes(AsyncStream.kt:570)
     at com.soywiz.korio.net.ws.RawSocketWebSocketClient.internalConnect(RawSocketWebSocketClient.kt:117)
     at com.soywiz.korio.net.ws.RawSocketWebSocketClient$internalConnect$1.invokeSuspend(Unknown Source:11)
     at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
     at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
     at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
     at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
     at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
     at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)

I got the following warning, it seems that korio is not compatibility with kotlin 1.4
w: Skipping "/Users/admin/.gradle/caches/modules-2/files-2.1/com.soywiz.korlibs.korio/korio-iosx64/1.11.13/200621a5861b1c6c286fee73bd6883218957fda5/korio.klib" as it is a pre 1.4 library

Korio is working well itself for android-only project. Multiplatform is broken.

The issue is caused by its dependecies. Korio 1.11.13 has klock 1.11.9 dependency. Korio is compiles and working normally in android-only project, but using any of klock components (such as DateTime constructor) crashes app with
java.lang.NoSuchMethodError: No virtual method invoke-TZYpA4o(J)D in class Lcom/soywiz/klock/DateTime$Companion; or its super classes

I have some investigations of APK binary file with Klock 1.11.9. My simple call of DateTime(0) transforms to DateTime.Companion.invoke-TZYpA4o(0), and there is no such method found in decompiled DateTime.
Original invoke(unix: kotlin.Double) method is declared as public final double invoke(double unix) in compiled code.

With klock 1.12.0 my call of DateTime(0) transforms to DateTime.Companion.m132invokeTZYpA4o(0) and there is such method in decompiled library code, declared as public final double m132invokeTZYpA4o(long unix).

So this issues is linked to kotlin compiler and dependency resoltion for libraries that are compiled with different kotlin versions. Building korio with kotlin 1.4 should fix that inconsistency I think.

Yeah, multiplatform requires compiling for each major release due maily to K/N and JS.
We plan to release a version of the libraries this week compiled against 1.4 unless some regressions on the Kotlin 1.4 compiler prevents us from doing so

@soywiz waiting for update

Need iOS support with Kotlin 1.4.0

@soywiz hello any news with KN 1.4 support? When I try to compile with XCode I get

Showing Recent Messages

w: Skipping "/Users/user/.gradle/caches/modules-2/files-2.1/com.soywiz.korlibs.korio/korio-iosarm64/1.11.13/9faa360d9197328fbd4557ddcf709cf555e17091/korio.klib" as it is a pre 1.4 library

e: Could not find "/Users/user/.gradle/caches/modules-2/files-2.1/com.soywiz.korlibs.korio/korio-iosarm64/1.11.13/9faa360d9197328fbd4557ddcf709cf555e17091/korio.klib" in [/Users/user/Documents/xcode/mingli_ios/projects/KotlinMultiplatformLibrary/iosApp, /Users/user/.konan/klib, /Users/user/.konan/kotlin-native-prebuilt-macos-1.4/klib/common, /Users/user/.konan/kotlin-native-prebuilt-macos-1.4/klib/platform/ios_arm64].

Thanks for your patience. Just triggered this release against Kotlin 1.4: https://github.com/korlibs/korio/releases/tag/v1.12.0
Once the build completes, it should be available: https://github.com/korlibs/korio/actions/runs/244629419

Bear in mind that Kotlin 1.4.0 have some regressions and bugs, and that's why I had to change code to circumvent those issues and took longer.

Unless there are important bugs, I do not plan to make more 1.x releases. Next version will be 2.0.0 targeting Kotlin 1.4. And that development happens here: https://github.com/korlibs/korge-next