I am trying to debug coroutines and followed the below resources to enable in Android Studio,
but unfortunately, I don't see the coroutine tab at all!! (below screenshot)
Coroutine library version,
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.2"
and my Kotlin plugin version is 1.4.21
Why do I still not see the coroutine debug tab?
In the Project Structure dialog, go to Project Settings | Libraries, press "+" button and select "From Maven..." in the popup. In the dialog that appears, enter the name and version of the library you need, which you can find out in the documentation. (For the current version of the core library of kotlinx.
launch. The simplest way to create a coroutine is by calling the launch builder on a specified scope. It Launches a new coroutine without blocking the current thread and returns a reference to the coroutine as a Job. The coroutine is canceled when the resulting job is canceled.
Step 1. Go to Tools → Kotlin → Configure Kotlin Plugin Updates, select “Stable” in the Update channel drop-down list, and then click Check for updates. We are adding coroutines-core along with coroutines-android. Now, sync your project with gradle files and you are ready use the latest Coroutines.
Run the code in debug mode by clicking Debug next to the run configuration at the top of the screen. The Frames tab contains the call stack. The Variables tab contains variables in the current context. The Coroutines tab contains information on running or suspended coroutines. It shows that there are three coroutines.
The Coroutines tab contains information on running or suspended coroutines. It shows that there are three coroutines. The first one has the RUNNING status, and the other two have the CREATED status. Resume the debugger session by clicking Resume Program in the Debug tool window:
Click in the top-right corner of the Debug tool window, then click Restore Default Layout. You can arrange the tabs to fit your preference. You can move a tab to another location or group a tab with another tab, so that they share the same space on the screen. Drag the tab header to the desired location.
The first coroutine has the SUSPENDED status – it is waiting for the values so it can multiply them. The second coroutine has computed its value and disappeared. The third coroutine is calculating the value of b – it has the RUNNING status. Using IntelliJ IDEA debugger, you can dig deeper into each coroutine to debug your code.
As far as I know coroutine debugger is not yet available on android at all. This question was brought up during the kotlin event in October and here is the answer from the kotlin devs.
Update: coroutines debugger for android has been finally announced on Google IO 2021!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With