Using kotlinx.coroutines in IntelliJ IDEA project

You should add kotlin coroutines library to your project. The simplest way to do it is to get it from Maven repo. At this moment actual version of library is 1.3.2 The address of library in maven repo you could find here

At moment of writing the address of library is

org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2

In plain IDEA IntelliJ project you should make following steps:

1) Go to project structure enter image description here

2) Then go to Modules page and Dependencies Tab enter image description here

3) Press "+" button. Select library from "Maven"

enter image description here

4) In search bar use address org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2 of library in maven repo and add it. enter image description here

5) Press OK then Apply. And recompile your project. That is it. Now you could use coroutines in your project.

enter image description here


runBlocking and other high-level coroutine utilities are not in the Kotlin standard library, but instead are a part of the library kotlinx.coroutines.

To use this library in your project you must download its binaries and add a dependency on them to the project. Usually declaring a library dependency is a line or couple of lines in a build file, if you use build systems like Gradle or Maven. However in a plain IntelliJ project it's possible to get that library from Maven Central almost without hassle:

  • Open project structure
  • In the "Modules" page select a module which you use as a context of the scratch file (I suppose there will be just one module).
  • Switch to "Dependencies" tab and hit the plus button.
  • then in a context menu select "Library" -> "From Maven"
  • paste maven coordinates of the kotlinx.coroutines library artifact:

    org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3

    where 1.3.3 is the version of that library. You can find the latest available version here: https://github.com/Kotlin/kotlinx.coroutines/blob/master/README.md

  • be sure to check "Transitive dependencies" and "Sources" boxes.

After hitting OK the library will be downloaded from Maven Central repository with all its dependencies and added to your module. Then it will be possible to use runBlocking in your project or scratch files.