Home > Software design >  IntelliJ: After adding coroutine, compilation failes with "unresolved reference: kotlinx"
IntelliJ: After adding coroutine, compilation failes with "unresolved reference: kotlinx"

Time:01-03

After adding the library jetbrains.kotlinx.coroutines.core.jvm, the IDE seems to show coroutine-related classes in the auto-complete (first image below). However, building the source code below

import kotlinx.coroutines.*

fun main(args: Array<String>) {
}

fails with "Main.kt: (1, 8): Unresolved reference: kotlinx". Why is this so? I added the library in Project Settings -> Modules -> untilted3 (project name) and main (at first I added it to main, then I also added it untiled3) -> Dependencies, as the second image below.

enter image description here

enter image description here

enter image description here

CodePudding user response:

Generally, as long as I know, this problem is due to a plugin that needs to be added to Gradle Project's file apply plugin: 'kotlin-android-extensions'

  • Related