Kotlinx.coroutines: Throwing exceptions inside coroutines generates warnings on Android 9 devices

Created on 12 Nov 2018  路  6Comments  路  Source: Kotlin/kotlinx.coroutines

Running this code on Android 9 device/emulator:

GlobalScope.launch {
    throw IllegalStateException()
}

will result in a Accessing hidden method Ljava/lang/Thread;->getUncaughtExceptionPreHandler()Ljava/lang/Thread$UncaughtExceptionHandler; (light greylist, reflection) warning printed into Logcat.

Android 9 includes crackdown on developers using non-public stuff via reflection, and looks like coroutines got caught in this.

enhancement help wanted

All 6 comments

We are happy to use an official API, could you please point to the legal ways to handle an exception?
We can't just call Thread.defaultExceptionHandler (see #148), it does not log an exception but crash an application.

To be honest, I have no solution.

I think best bet is to Create ticket about this on Google's tracker and see what they think about it.

cc @adamp 鈽濓笍

The issue tracker link above is the right place to propagate this question for now. In the meantime iirc you should only see the warning once during the reflection lookup, subsequent invocations should be quiet. I can try to take a look in some more detail next week.

@qwwdfsad Thanks for the fix. Is this available in a release?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LouisCAD picture LouisCAD  路  64Comments

Tolriq picture Tolriq  路  50Comments

elizarov picture elizarov  路  40Comments

NikolayMetchev picture NikolayMetchev  路  46Comments

elizarov picture elizarov  路  62Comments