You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am getting a crash when I try to call a suspend method from an rx chain. The rx chain previously had a method that was returning Single<SomeType> which is now changed to a suspend method. But when I use rxSingle to change the behavior to return Single , it crashes with the following log,
java.lang.NoSuchMethodError: No direct method <init>(Lkotlin/coroutines/CoroutineContext;Z)V in class Lkotlinx/coroutines/AbstractCoroutine; or its super classes (declaration of 'kotlinx.coroutines.AbstractCoroutine' appears in /data/app/com.paystack.pos.staging-3/base.apk:classes18.dex)
at kotlinx.coroutines.rx2.RxSingleCoroutine.<init>(RxSingle.kt:56)
at kotlinx.coroutines.rx2.RxSingleKt$rxSingleInternal$1.subscribe(RxSingle.kt:48)
at io.reactivex.internal.operators.single.SingleCreate.subscribeActual(SingleCreate.java:39)
at io.reactivex.Single.subscribe(Single.java:3603)
at io.reactivex.internal.operators.single.SingleFlatMap.subscribeActual(SingleFlatMap.java:36)
at io.reactivex.Single.subscribe(Single.java:3603)
at io.reactivex.Single.subscribeWith(Single.java:3650)
I tried to do this in a test and it crashed with the same reason as above.
suspend fun sayHello(): String {
delay(1000)
return "Hello"
}
fun sayHelloSingle(): Single<String> = rxSingle { sayHello() }
@Test
fun testSingle(){
sayHelloSingle().test().assertValue("Hello")
}
Not sure what I am doing wrong. I am using version 1.4.3 for both org.jetbrains.kotlinx:kotlinx-coroutines-rx2 and org.jetbrains.kotlinx:kotlinx-coroutines-core and version 2.2.10 for rxJava. Thank you for the help 🙏🏼
The text was updated successfully, but these errors were encountered:
Hi, it seems like you have mismatched versions of kotlinx-coroutine-rx2 and kotlinx-coroutines-core. It's likely that higher version comes from some dependency transitively and wins gradle dependency resolution. ./gradlew :yourTask --scan can provide an additional insight for you.
There are multiple options:
Figure out where the inconsistency comes from and fix it by forcing the version
Hi,
I am getting a crash when I try to call a
suspend
method from an rx chain. The rx chain previously had a method that was returningSingle<SomeType>
which is now changed to a suspend method. But when I userxSingle
to change the behavior to returnSingle
, it crashes with the following log,I tried to do this in a test and it crashed with the same reason as above.
Not sure what I am doing wrong. I am using version
1.4.3
for bothorg.jetbrains.kotlinx:kotlinx-coroutines-rx2
andorg.jetbrains.kotlinx:kotlinx-coroutines-core
and version2.2.10
for rxJava. Thank you for the help 🙏🏼The text was updated successfully, but these errors were encountered: