Oliver.O
07/03/2023, 11:37 AMUnresolved reference: kotlinx
recently on imports like import kotlinx.coroutines.channels.Channel
?
Details in 🧵.Oliver.O
07/03/2023, 11:38 AMUnresolved reference: kotlinx
on import statements like this:
import kotlinx.coroutines.channels.Channel
This is what I tried:
1. Gradle clean
2. Restart IDE
3. Re-sync Gradle projects
4. Use IDEA 2023.2 EAP
5. Use IDEA 2023.1.3 with Kotlin Plugin 231-1.8.21-IJ9161.38
This is what helped in the end:
• Add a redundant dependency in commonMain
val commonMain by getting {
dependencies {
// ...
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.2") // <- added redundantly
implementation(KotlinX.coroutines.core) // <- existed before, using refreshVersions with version.kotlinx.coroutines=1.7.2
// ...
}
}
Adding the redundant dependency made the above error disappear. Removing the redundant dependency afterwards was OK. The error did not reappear.
Any idea which kind of (supposedly caching) problem is causing this?Adam S
07/03/2023, 11:50 AMKotlinX.coroutines.core
has a GAV of org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.2
and not a variant, e.g. org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.7.2
? Can you add a println()
to try and get the actual GAV of KotlinX.coroutines.core
?Adam S
07/03/2023, 11:52 AMkotlin.mpp.import.enableKgpDependencyResolution=true
to gradle.properties https://kotlinlang.org/docs/whatsnew1820.html#preview-of-gradle-composite-builds-support-in-kotlin-multiplatformOliver.O
07/03/2023, 12:46 PM_println_(KotlinX.coroutines.core)
yields org.jetbrains.kotlinx:kotlinx-coroutines-core:_
(the underscore is dealt with by refreshVersions
).
I'm not using composite builds in this case. However, trying enableKgpDependencyResolution
might be a good idea anyway as it includes:
major bug fixes and improvements to make the import more stableThe strange thing is that this was only an intermittent problem which I can't reproduce any longer once it was resolved. Might even be a collateral of Kotlin IDE plugin crashes which I had seen a lot. In any case it would be useful to know where the plugin stores things and how to reset that.
Oliver.O
07/03/2023, 12:56 PMkotlin.mpp.import.enableKgpDependencyResolution=true
made the error reappear (the redundant dependency trick did not work then). Removing enableKgpDependencyResolution
solved the issue.Adam S
07/03/2023, 1:12 PMOliver.O
07/03/2023, 1:15 PMAdam S
07/03/2023, 1:16 PMOliver.O
07/03/2023, 1:32 PMAdam S
07/03/2023, 1:34 PMOliver.O
07/04/2023, 1:32 PMSebastian Sellmair [JB]
07/06/2023, 8:55 PMSebastian Sellmair [JB]
07/06/2023, 9:04 PMOliver.O
07/06/2023, 9:05 PMenableKgpDependencyResolution=true
.
And since I wanted to check the new source set hierarchy, too, I've come up with another one: https://youtrack.jetbrains.com/issue/KT-60173/KotlinTargetHierarchy-Support-multiple-Jvm-targets
Summing it up, it seems there is not that much that is missing, so I wanted to give as much feedback as early as possible.Sebastian Sellmair [JB]
07/06/2023, 9:06 PMSebastian Sellmair [JB]
07/06/2023, 9:07 PMSebastian Sellmair [JB]
07/06/2023, 9:07 PMOliver.O
07/06/2023, 9:08 PMSebastian Sellmair [JB]
07/06/2023, 9:17 PMSebastian Sellmair [JB]
07/06/2023, 9:17 PMOliver.O
07/06/2023, 9:19 PMcommon
frontendCommon
frontendUi
frontendJvm (Compose Desktop target)
frontendJsUi (Compose Web target)
frontendJs
frontendJsUi (*)
commonJvm
frontendJvm (*)
integrationJvm (Backend + Compose Desktop target)
backendJvm (Ktor server target)
integrationJvm (*)
(*) additional dependency
Sebastian Sellmair [JB]
07/06/2023, 9:20 PMOliver.O
07/06/2023, 9:23 PMSebastian Sellmair [JB]
07/06/2023, 9:28 PMSebastian Sellmair [JB]
07/06/2023, 9:29 PMSebastian Sellmair [JB]
07/06/2023, 9:30 PMOliver.O
07/06/2023, 9:31 PMSebastian Sellmair [JB]
07/06/2023, 9:31 PMSebastian Sellmair [JB]
07/06/2023, 9:31 PMOliver.O
07/06/2023, 9:34 PMSebastian Sellmair [JB]
07/06/2023, 9:38 PMOliver.O
07/06/2023, 9:43 PMOliver.O
07/18/2023, 5:10 PM