Kotlinx.coroutines: ClassCastException in 0.30.2 after obfuscation

Created on 15 Oct 2018  路  2Comments  路  Source: Kotlin/kotlinx.coroutines

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>;
}

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

-keepnames class kotlinx.coroutines.experimental.internal.MainDispatcherFactory {}

to your proguard rules.

All 2 comments

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.

Was this page helpful?
0 / 5 - 0 ratings