https://kotlinlang.org logo
Title
z

zak.taccardi

02/15/2019, 10:14 PM
Can a project that uses stable coroutines (
1.1.1
) include a library that uses experimental coroutines (
0.30.2
)?
b

bdawg.io

02/15/2019, 10:29 PM
You need to choose which one will be included (I’d recommend stable). Any
1.1.1
APIs should work with
0.30.2
if there’s still binary compatibility (the method wasn’t removed or changed in a backwards-incompatible way)
z

zak.taccardi

02/15/2019, 10:37 PM
I'm getting a runtime error of
Failed resolution
of a
kotlinx.coroutines.experimental.CompletableDeferredKt
from the 3rd party library that internally uses
0.30.2
coroutines
b

bdawg.io

02/15/2019, 11:16 PM
Oh right. Yeah,
kotlinx.coroutines.experimental.*
was moved to just
kotlinx.coroutines.*
which is not binary-compatible
l

louiscad

02/16/2019, 12:42 AM
So the simple answer is no. Is that library open source? Maybe you can link it?
z

zak.taccardi

02/16/2019, 12:42 AM
Currently on
2.3.1
, which depends on pre-stable coroutines
2.6.1
brings along Kotlin
1.3
and stable coroutines, but also AndroidX which we're not ready to bring in yet
Ideally we'd be able to temporarily run stable and pre-release coroutines alongside each other, but I guess that isn't possible
My team works on an internal company SDK, and we can't force our clients to upgrade to AndroidX yet
l

louiscad

02/16/2019, 12:48 AM
And also, for the longer term, here's a WIP project to have the Camera2 API with coroutines without technical debt: https://github.com/Beepiz/CameraCoroutines I'll work on it in the coming weeks/months and hopefully release a version that properly implements structured concurrency, has a nice API (it's currently a prototype, started before structured concurrency) and redirects all errors correctly. Watch releases on it if you're interested.
👍 1
z

zak.taccardi

02/16/2019, 12:52 AM
Can AndroidX and the support library live side by side in the same app? I'm on an SDK team inside my company, and we can't force my company's main app to upgrade to AndroidX before they're ready
l

louiscad

02/16/2019, 12:56 AM
An app that uses AndroidX dependent dependencies needs to be migrated to AndroidX itself. It can also use libraries dependent on support libraries with jetifier. So you need to first migrate the apps, then migrate all the libraries. You should not wait to do so IMHO.
The script instructions I linked above for AndroidX migration (as an alternative to IDE's slow option) rely on a script made in Kotlin that you're likely to understand yourself. Worked perfectly for several projects in my case, and for some other persons which gave positive feedback too.
e

elizarov

02/16/2019, 12:52 PM
You can include both stable & experimental coroutines, but you’ll need some gradle trickery. The simplest approach would be to download the old experimental coroutines .jar and include it via a file dependency.
👍 2