JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
16.25k stars 1.18k forks source link

Resolution error when building a canvas-based app for k/js #2255

Closed eymar closed 1 year ago

eymar commented 2 years ago

Originally reported here: https://kotlinlang.slack.com/archives/C01F2HV7868/p1660836369631249

In compose-jb 1.2.0-alpha01-dev755 with Web/Canvas/Skiko, I'm getting a symbol resolution error today Module "androidx.compose.foundation:foundation" has a reference to symbol [...] EmptyLazyGridLayoutInfo. It did work a couple of days ago. Re-downloaded the artifacts to no avail. Could it be that there's something wrong in the JB space repo?

> Task :compileDevelopmentExecutableKotlinFrontendJs FAILED
15 actionable tasks: 11 executed, 4 up-to-date
e: Module "androidx.compose.foundation:foundation" has a reference to symbol [ File '/mnt/agent/work/24a6d4ab147eab50/compose/frameworks/support/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/grid/LazyGridLayoutInfo.kt' <- androidx.compose.foundation.lazy.grid/EmptyLazyGridLayoutInfo|null[0] ]. Neither the module itself nor its dependencies contain such declaration.

This could happen if the required dependency is missing in the project. Or if there is a dependency of "androidx.compose.foundation:foundation" that has a different version in the project than the version that "androidx.compose.foundation:foundation" was initially compiled with. Please check that the project configuration is correct and has consistent versions of all required dependencies.

The list of "androidx.compose.foundation:foundation" dependencies that may lead to conflicts:
 1. "kotlin" (a library with unknown version)
 2. "androidx.compose.animation:animation" (a library with unknown version)
 3. "androidx.compose.animation:animation-core" (a library with unknown version)
 4. "androidx.compose.foundation:foundation-layout" (a library with unknown version)
 5. "androidx.compose.runtime:runtime" (a library with unknown version)
 6. "androidx.compose.runtime:runtime-saveable" (a library with unknown version)
 7. "androidx.compose.ui:ui" (a library with unknown version)
 8. "androidx.compose.ui:ui-geometry" (a library with unknown version)
 9. "androidx.compose.ui:ui-graphics" (a library with unknown version)
10. "androidx.compose.ui:ui-text" (a library with unknown version)
11. "androidx.compose.ui:ui-unit" (a library with unknown version)
12. "androidx.compose.ui:ui-util" (a library with unknown version)
13. "org.jetbrains.skiko:skiko" (a library with unknown version)
14. "org.jetbrains.kotlin:kotlinx-atomicfu-runtime" (a dependency of the library with unknown version or versions mismatch: "org.jetbrains.kotlin:kotlinx-atomicfu-runtime")
15. "org.jetbrains.kotlinx:atomicfu" (a library with unknown version)
16. "org.jetbrains.kotlinx:kotlinx-coroutines-core" (a library with unknown version)

Project dependencies:
+--- kotlin
+--- androidx.compose.animation:animation
[...]
+--- androidx.compose.foundation:foundation
|    ^^^ This module requires symbol [ File '/mnt/agent/work/24a6d4ab147eab50/compose/frameworks/support/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/grid/LazyGridLayoutInfo.kt' <- androidx.compose.foundation.lazy.grid/EmptyLazyGridLayoutInfo|null[0] ].
|    +--- kotlin
[...]

Reproducer: https://github.com/OliverO2/compose-web-canvas-symbol-missing

noheltcj commented 2 years ago

This also happens when I reference pretty much anything in the androidx.compose.foundation.lazy.grid package in a source set that's depended upon by an iOS target:

e: Module "org.jetbrains.compose.foundation:foundation" has a reference to symbol [ File '/opt/buildAgent/work/ba60555d9dde92ae/compose/frameworks/support/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/grid/LazyGridLayoutInfo.kt' <- androidx.compose.foundation.lazy.grid/EmptyLazyGridLayoutInfo|null[0] ]. Neither the module itself nor its dependencies contain such declaration.

This could happen if the required dependency is missing in the project. Or if there is a dependency of "org.jetbrains.compose.foundation:foundation" that has a different version in the project than the version that "org.jetbrains.compose.foundation:foundation" was initially compiled with. Please check that the project configuration is correct and has consistent versions of all required dependencies.

The list of "org.jetbrains.compose.foundation:foundation" dependencies that may lead to conflicts:
 1. "org.jetbrains.compose.animation:animation" (a library with unknown version)
 2. "org.jetbrains.compose.animation:animation-core" (a library with unknown version)
 3. "org.jetbrains.compose.foundation:foundation-layout" (a library with unknown version)
 4. "org.jetbrains.compose.runtime:runtime" (a library with unknown version)
 5. "org.jetbrains.compose.runtime:runtime-saveable" (a library with unknown version)
 6. "org.jetbrains.compose.ui:ui" (a library with unknown version)
 7. "org.jetbrains.compose.ui:ui-geometry" (a library with unknown version)
 8. "org.jetbrains.compose.ui:ui-graphics" (a library with unknown version)
 9. "org.jetbrains.compose.ui:ui-text" (a library with unknown version)
10. "org.jetbrains.compose.ui:ui-unit" (a library with unknown version)
11. "org.jetbrains.compose.ui:ui-util" (a library with unknown version)
12. "org.jetbrains.skiko:skiko" (a library with unknown version)
13. "stdlib: 1.7.10" (was initially compiled with "stdlib: 1.6.21")
14. "org.jetbrains.kotlin.native.platform.CoreFoundation: 1.7.10" (was initially compiled with "org.jetbrains.kotlin.native.platform.CoreFoundation: 1.6.21")
15. "org.jetbrains.kotlin.native.platform.CoreGraphics: 1.7.10" (was initially compiled with "org.jetbrains.kotlin.native.platform.CoreGraphics: 1.6.21")
16. "org.jetbrains.kotlin.native.platform.CoreImage: 1.7.10" (was initially compiled with "org.jetbrains.kotlin.native.platform.CoreImage: 1.6.21")
17. "org.jetbrains.kotlin.native.platform.CoreText: 1.7.10" (was initially compiled with "org.jetbrains.kotlin.native.platform.CoreText: 1.6.21")
18. "org.jetbrains.kotlin.native.platform.CoreVideo: 1.7.10" (was initially compiled with "org.jetbrains.kotlin.native.platform.CoreVideo: 1.6.21")
19. "org.jetbrains.kotlin.native.platform.EAGL: 1.7.10" (was initially compiled with "org.jetbrains.kotlin.native.platform.EAGL: 1.6.21")
20. "org.jetbrains.kotlin.native.platform.Foundation: 1.7.10" (was initially compiled with "org.jetbrains.kotlin.native.platform.Foundation: 1.6.21")
21. "org.jetbrains.kotlin.native.platform.IOSurface: 1.7.10" (was initially compiled with "org.jetbrains.kotlin.native.platform.IOSurface: 1.6.21")
22. "org.jetbrains.kotlin.native.platform.ImageIO: 1.7.10" (was initially compiled with "org.jetbrains.kotlin.native.platform.ImageIO: 1.6.21")
23. "org.jetbrains.kotlin.native.platform.Metal: 1.7.10" (was initially compiled with "org.jetbrains.kotlin.native.platform.Metal: 1.6.21")
24. "org.jetbrains.kotlin.native.platform.OpenGLESCommon: 1.7.10" (was initially compiled with "org.jetbrains.kotlin.native.platform.OpenGLESCommon: 1.6.21")
25. "org.jetbrains.kotlin.native.platform.QuartzCore: 1.7.10" (was initially compiled with "org.jetbrains.kotlin.native.platform.QuartzCore: 1.6.21")
26. "org.jetbrains.kotlin.native.platform.Security: 1.7.10" (was initially compiled with "org.jetbrains.kotlin.native.platform.Security: 1.6.21")
27. "org.jetbrains.kotlin.native.platform.UIKit: 1.7.10" (was initially compiled with "org.jetbrains.kotlin.native.platform.UIKit: 1.6.21")
28. "org.jetbrains.kotlin.native.platform.UserNotifications: 1.7.10" (was initially compiled with "org.jetbrains.kotlin.native.platform.UserNotifications: 1.6.21")
29. "org.jetbrains.kotlin.native.platform.darwin: 1.7.10" (was initially compiled with "org.jetbrains.kotlin.native.platform.darwin: 1.6.21")
30. "org.jetbrains.kotlin.native.platform.posix: 1.7.10" (was initially compiled with "org.jetbrains.kotlin.native.platform.posix: 1.6.21")
31. "org.jetbrains.kotlinx:atomicfu (org.jetbrains.kotlinx:atomicfu-iosx64): 0.17.3" (was initially compiled with "org.jetbrains.kotlinx:atomicfu (org.jetbrains.kotlinx:atomicfu-iosx64)")
32. "org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-iosx64): 1.6.4" (was initially compiled with "org.jetbrains.kotlinx:kotlinx-coroutines-core (org.jetbrains.kotlinx:kotlinx-coroutines-core-iosx64)")

Can confirm that simply commenting out those references results in a successful build / run (not a workaround since I'm just omitting a portion of the UI). Hopefully this helps!

eymar commented 2 years ago

reproduced also with older versions (didn't find a version where it worked) when using androidx.compose.foundation.lazy.grid.LazyGridState anywhere in the source code.

eymar commented 2 years ago

the change in androidx/compose that revealed the issue:

LazyGridLayoutInfo was interface, but became sealed interface

- interface LazyGridLayoutInfo {
+ sealed interface LazyGridLayoutInfo {

https://youtrack.jetbrains.com/issue/KT-54028/Using-private-object-implementing-a-sealed-interface-causes-a-linker-error

YoshiRulz commented 2 years ago

I believe this is fixed as of 1.2.0-beta01.

eymar commented 1 year ago

Fixed

okushnikov commented 2 months ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.