Reputation: 1480
This line:
import kotlinx.coroutines.*
Gives me Unresolved reference: kotlinx
error.
My project creation process is very basic:
In Intellij Idea: New project -> Kotlin -> JVM
My project structure:
Maybe I need to configure something somewhere?
SOLUTION:
I was creating my Kotlin app the wrong way. Finally I followed this tutorial: https://huongdankotlin.com/create-a-new-gradle-project-with-kolin-using-intellij.html
Then on kotlin (in src folder) -> new package -> kotlin file.
And then add implementation("org.jetbrains.kotlinx", "kotlinx-coroutines-core", "1.5.2")
inside dependencies
in the build.gradle.kts
Now it worked for me.
Upvotes: 1
Views: 2191
Reputation: 23357
As mentioned in the Android documentation about coroutines you need to add the dependency to it in your gradle file to be able to use it like
dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0'
}
EDIT: I missed that the question is not about an Android project. I'll leave the answer here as it might help android developers.
Upvotes: 3