Kotlin, Android, how to debug coroutines correctly?
Based on your sample code, you switch the coroutine context between MAIN
and IO
so when you set the breakpoint, make sure the suspend
option is ALL
To show the option of the breakpoint. Set a breakpoint with the left click of your mouse, and then right click your mouse on the breakpoint.
If you are using the JetBrain IDE, according to the document, when you set the breakpoint to make sure the suspend
option is ALL
not thread. it works for me.
and more detail you can check the document
It still does not work for me because I run the app first then attach the debugger, but when I use debug instead, it works.