Reputation: 29
I am trying to delay a task by 1 second using coroutines but when I try importing kotlinx.coroutines.* it says unresolved reference.
Upvotes: 2
Views: 2138
Reputation: 615
If you use IntelliJ IDEA, you can do the following:
1 - File -> Project Structure
2 - In the side menu go to "Modules" and you will have the option to "Add -> Library -> From Maven".
3 - Add these 2 Kotlin coroutines libraries:
and select the checkboxes: "Download To" + "Transitive Dependencies" + "Sources".
4 - After this all the dependencies of the coroutines in Kotlin are downloaded and compiled.
Note: If you want to see the latest versions of the Kotlin coroutines you can go directly to:
https://github.com/Kotlin/kotlinx.coroutines/blob/master/README.md#using-in-your-projects
Upvotes: 1
Reputation: 28865
In build.gradle
of app folder you should add these libraries:
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.61"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2'
}
Upvotes: 2