在Android中调试Kotlins协同程序

Nul*_*ter 6 debugging android kotlinx.coroutines

是否有可能在Android中调试协同程序?当我尝试调试此代码段时:

runBlocking {
        try {
            async(CommonPool) {
                showLoadingIndicator()
                val a = loadData().await()
                hideLoadingIndicator()
            }
        } catch (e: Exception) {
            Log.e("lala", "exception " + e.toString())
        }
}
Run Code Online (Sandbox Code Playgroud)

val a有以下消息: Cannot find local variable: name = a

在我的应用程序中,我正在设置coroutines调试的属性,如下所示:

System.setProperty("kotlinx.coroutines.debug", if (BuildConfig.DEBUG) "on" else "off")
Run Code Online (Sandbox Code Playgroud)

还是行不通.现在我不知道在使用协同程序时如何使用调试器.愿你们帮帮我吧?

提前致谢

阿尔班

Ger*_*dus -1

我通常会添加System.err.println(a)一行,这样如果我停在那里,则a需要在那里,以便我可以验证它的值。

不太可扩展,但对于调试来说它对我来说很有效。