Hello Devs. I just wanted to taste `coroutines`. U...
# announcements
n
Hello Devs. I just wanted to taste
coroutines
. Unfortunately, I haven't been able to use the library
kotlinx
in
idea
for two hours. 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. 🙄
c
can you post a small reproduceable example on github? or a gist if it's small enough?
n
@crummy There is so much less code to be shared. But I can share screen shots of each step of the process I am using. I would post the gist once it has been created. Thank you.
c
You could also try starting a brand new project, seeing if you can repro it then
j
The things I can think of is: • Are you using Java Modules, if so, have you added the coroutines to your
module-info.java
? IntelliJ should complain, but it's easily missed. • Are you using maven/gradle for dependencies? Is your project set up to use the classpath from them? It should be done automatically if you create the project as maven/gradle, but I'm not sure if IntelliJ does it otherwise. This also applies to running the app using the internal runner instead of maven/gradle. Basic things, but so easy to miss.
n
@Jimmy Thanks for your input. But I am really new to the
gradle/maven
stuff and don't understand these properly.
@Jimmy @crummy I have added my query to
Stackoverflow
. I've explained all the steps that I am following with snapshots. You can check it out here, https://stackoverflow.com/questions/68150001/unresolved-reference-kotlinx-in-intellijidea-even-after-adding-the-library
j
You really should learn to use a build system, it will make your life easier. 🙂 You're missing the dependencies for the coroutines, either add
kotlinx-coroutines-core-jvm
or, redo the project using Gradle (IMO the better system over Maven) instead of IntelliJ. Then it should be enough to just add
Copy code
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0")
❤️ 1
c
I agree - using Maven or Gradle will make this easier (and is how 99% of projects work too)
👍 1
n
@Jimmy @crummy Thank you so much. I would spend my evening learning about Gradle. Though, I have added
kotlinx-coroutines-core-jvm
for now. And it works like a charm.
👍 1
g
Yeah, issue in this case is becasuse of org.jetbrains.kotlinxkotlinx coroutines core1.5.0, it is metadata dependency, which doesn’t include actual code, and have metadata config to reference platform specific dependencies (like jvm, js, different flavours of native), and metadata is supported only by Gradle, even not sure that Maven can handle it. Though, probably worth to report it for Intellij tracker, JSP (intellij built-in build system) probably should support it, or at least report that Gradle metadata is not supported