https://kotlinlang.org logo
#coroutines
Title
# coroutines
s

sindrenm

10/26/2018, 11:28 AM
Does anyone know why it would be a problem using both kotlinx.coroutines.experimental and kotlinx.coroutines (non-experimental) in the same project? Or rather, have one library that uses the experimental coroutines (with Kotlin 1.2) and in the app that consumes the library use the stable coroutines (and thus Kotlin 1.3, of course). Our app crashes when the library attempts to then refer to something from the experimental coroutines library:
java.lang.NoClassDefFoundError: Failed resolution of: Lkotlinx/coroutines/experimental/BuildersKt;
b

bdawg.io

10/26/2018, 1:57 PM
They are not binary compatible so you can't mix experimental and non-experimental
e

elizarov

10/26/2018, 2:54 PM
Can you, please, give more details on how exactly this mix happens to come about.
s

sindrenm

10/26/2018, 3:35 PM
Definitely! We are developing an Android app. And there is a library (let's call it “messaging”) that uses Kotlin 1.2.71. They also use the kotlinx.coroutines stufff from version 0.23.4 (not EAP, of course). Our app depends on “messaging”. However, for all the good reasons, our app wants to use the Kotlin 1.3 RC. And we also want to use the stable coroutines implementation along with all the other goodies. Initially, when building our debug versions of the app, which does not do any minification or anything, we were able to build just fine and run the app. However, when we reach the parts of the code in the “messaging” library that uses kotlinx.coroutines.experimenta.*, it crashes hard with this exception:
java.lang.NoClassDefFoundError: Failed resolution of: Lkotlinx/coroutines/experimental/BuildersKt;
I imagine it crashes here first because this is the first time something is being referenced. If, when building a release version of the app (which does indeed minify), it won't sync properly because of this error, likely from ProGuard:
com.schibsted.domain.messaging.tracking.TrackerManager: can't find referenced class kotlinx.coroutines.experimental.BuildersKt
Adding the ProGuard rules documented (https://github.com/Kotlin/kotlinx.coroutines/tree/0.23.4#proguard), the sync/build issue goes away, but it still crashes at runtime with the same exception.
e

elizarov

10/26/2018, 3:36 PM
How exactly this “messaging” app is using coroutines? Internally? Does it expose any suspending functions that you are calling?
Is it an internal messaging library or open-source?
s

sindrenm

10/26/2018, 3:41 PM
It is unfortunately not open-source, but developed “internally” by a “partner”. I don't believe we are calling in to the suspending functions ourselves. Let me take a look. simple smile
e

elizarov

10/26/2018, 3:42 PM
Anyway, the best way would be to ask to the to build a version of the library for Kotlin 1.3.0-RC with non-experimental coroutines and 1.0.0-RC1 version of the
kotlinx.coroutines
They can produce a version just for you initially, and if that works fine take it into their main branch
s

sindrenm

10/26/2018, 3:43 PM
Nope, definitely not calling any suspended functions from our app into the lib.
Yeah, I have been chatting with them about this already. I'm not entirely sure if they'll be able to do that, but I'll see what comes of it. :-)
e

elizarov

10/26/2018, 3:46 PM
Please, keep us posted whether it works for you.
s

sindrenm

10/26/2018, 3:46 PM
Alright, I'll do that. Thanks!
So, no progress yet, but now that 1.3 is out (🎉🌮🎅), I'm pushing for a new release of the library instead. Thanks for the chat, anyway. 😀
6 Views