Unresolved Reference Kotlinx in IntellijIdea. Even after adding the library
Asked Answered
M

1

7

I just wanted to taste Kotlin coroutines. Unfortunately, I haven't been able to use the library kotlinx in IntelliJ. I have downloaded the library through Maven.

  1. Tried invalidating caches.
  2. Rebuilt project.
  3. Tried using it in a fresh project.
  4. Even IntelliJ is suggesting kotlinx in auto-completion.
  5. Still it says unresolved reference

I have tried most of the solutions on the web. But nothing worked.

Here are the steps that I am exactly doing.

made a new project

Made a new project.

enter image description here

kotlinx is underlined since the library has not been added.

enter image description here

In project structure > modules > dependencies > add > library > maven Searched for the kotlinx library.

enter image description here

Downloaded the library.

enter image description here

Applied the settings.

enter image description here

kotlinx library is now visible in the External Libraries section.

enter image description here

Even the auto-completion is now suggesting kotlinx.

enter image description here

Still, nothing changes. The result is the same.

Mixtec answered 27/6, 2021 at 10:4 Comment(0)
M
20

I have found the answer in the Kotlin slack channel. And to solve this particular issue add org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.0 instead of org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0.

However, it is generally a good idea to learn a build system like Gradleor Maven and using those in the project. It makes life a lot easier.

Mixtec answered 27/6, 2021 at 14:33 Comment(3)
How to do that? In Android Studio, I can add it by typing the library address directly in 'dependencies{}' of build.gradle. Navigating that deeply buried GUI only to type the same address is not convenient. Can't I type it directly in IntellJ as I do in AS?Radiopaque
Doesn't work. In the editor it does recognize the artifacts (e.g. runBlocking) but in the build time it doesn't. It says "Unresolved reference: kotlinx".Boracic
@AviTshuva It used to work but not sure why it isn't working anymore. Probably the latest version of Idea changed something. However, you can also use the shitty Gradle to add this dependency.Mixtec

© 2022 - 2024 — McMap. All rights reserved.