I created gradle java kotlin project. I want to use coroutines but I get unresolved reference launch and unresolved reference delay errors:
import java.util.*
import kotlinx.coroutines.*
fun main (args: Array<String>)
{
launch { // launch coroutine
delay(1000L)
println("World!")
}
println("Hello")
}
In build.gradle.kts I included this line in dependencies block:
implementation("org.jetbrains.kotlinx", "kotlinx-coroutines-core", "1.5.2")
EDIT:
My build.gradle.kts file:
plugins {
kotlin("jvm") version "1.5.10"
java
}
group = "org.example"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
implementation(kotlin("stdlib"))
testImplementation("org.junit.jupiter:junit-jupiter-api:5.6.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2")
}
tasks.getByName<Test>("test") {
useJUnitPlatform()
}
EDIT2: Everything fixed after clearing cache. You can do it in File->Invalidate caches