I have the crash in runtime in an obfuscated version of my android application.
The application contains simple code like:
launch {
...
withContext(UI) { ... }
}
Stacktrace after retrace:
java.lang.ClassCastException: kotlinx.coroutines.experimental.ay cannot be cast to kotlinx.coroutines.experimental.android.b
at kotlinx.coroutines.experimental.android.HandlerContextKt.getUI(Unknown Source)
at com.example.myapp.MainActivity$refreshCurrentAuthenticators$1.invoke(Unknown Source)
doResume
create
create
at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.getContext(Unknown Source)
resume
resumeWithException
doResume
create
at kotlinx.coroutines.experimental.DispatchedTask$DefaultImpls.getSuccessfulResult(Unknown Source)
run
at kotlinx.coroutines.experimental.DispatchedContinuation.run(Unknown Source)
at kotlinx.coroutines.experimental.scheduling.Task.run(Unknown Source)
at kotlinx.coroutines.experimental.scheduling.CoroutineScheduler.parkedWorkersStackTopUpdate(Unknown Source)
parkedWorkersStackPush
shutdown
dispatch
dispatch$default
createTask$kotlinx_coroutines_core
submitToLocalQueue
runSafely
access$getSchedulerName$p
access$runSafely
access$getMAX_PARK_TIME_NS$cp
access$parkedWorkersStackPush
access$parkedWorkersStackTopUpdate
at kotlinx.coroutines.experimental.scheduling.CoroutineScheduler.parkedWorkersStackTopUpdate(Unknown Source)
parkedWorkersStackPush
shutdown
dispatch
dispatch$default
createTask$kotlinx_coroutines_core
submitToLocalQueue
runSafely
access$getSchedulerName$p
access$runSafely
access$getMAX_PARK_TIME_NS$cp
access$parkedWorkersStackPush
access$parkedWorkersStackTopUpdate
at kotlinx.coroutines.experimental.scheduling.CoroutineScheduler$Worker.run(Unknown Source)
The application works well with 0.30.0 version
kotlin version 1.2.71
gradle 4.10.1
android gradle plugin 3.2.0
proguard-rules contains:
-keepclassmembernames class kotlinx.** {
volatile <fields>;
}
I create a sample of crash in a release build:
https://github.com/HotIceCream/CoroutinesSimpleExample/blob/master/app/src/main/java/com/github/hoticecream/coroutinessimpleexample/MainActivity.kt#L17
Thank you for the reproducer.
It appears to be the same bug as in #657. Will be fixed in 1.0.0-RC, workaround is to add
-keepnames class kotlinx.coroutines.experimental.internal.MainDispatcherFactory {}
to your proguard rules.
Most helpful comment
Thank you for the reproducer.
It appears to be the same bug as in #657. Will be fixed in 1.0.0-RC, workaround is to add
to your proguard rules.