Hello everyone, can someone tell me what's wrong w...
# getting-started
u
Hello everyone, can someone tell me what's wrong why coroutines doesn't work?
j
Did you add the coroutines library (
kotlinx-coroutines-core
) to your build script (
build.gradle.kts
)?
💯 1
u
where should I put?
j
You should add the coordinates of the coroutines library in the
dependencies { ... }
block. Something like:
Copy code
dependencies {
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
    testImplementation(kotlin("test"))
}
If you look it up, you will find the kotlinx.coroutines repository, and there are instructions on how to add the dependency: https://github.com/Kotlin/kotlinx.coroutines#gradle (This is the case for any well-documented library) This is where you can find the coordinates in the form
groupId:artifactId:version
. For coroutines 1.7.3, the coordinates are
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3
. This is why we add the line
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
.
💯 2
K 2
Most dependencies you will add will be with the
implementation(...)
configuration.
testImplementation
is for dependencies that are only used in your tests (this is why
kotlin("test")
is added with
testImplementation(...)
). You can learn more about these configuration in the documentation of the Gradle build tool, which is what you're using here. https://docs.gradle.org/current/userguide/declaring_dependencies.html
💯 2
u
Thank you for your help! Highly appreciated!💯