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.33k stars 1.18k forks source link

./gradle build for ImageViewer example fails #3079

Closed StefanOltmann closed 1 year ago

StefanOltmann commented 1 year ago

Running ./gradlew build on the current master (commit cbdb0eb) fails due do an issue with the coroutine dependency.

Building https://github.com/JetBrains/compose-multiplatform-template the same way works.

sol@MBP-von-Stefan imageviewer % ./gradlew build            
WARNING:We recommend using a newer Android Gradle plugin to use compileSdk = 33

This Android Gradle plugin (7.1.3) was tested up to compileSdk = 32

This warning can be suppressed by adding
    android.suppressUnsupportedCompileSdk=33
to this project's gradle.properties

The build will continue, but you are strongly encouraged to update your project to
use a newer Android Gradle Plugin that has been tested with compileSdk = 33

> Task :shared:compileIosMainKotlinMetadata FAILED
e: file:///Users/sol/Downloads/compose-multiplatform-master/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/ImageViewer.ios.kt:13:27 Unresolved reference: CoroutineScope
e: file:///Users/sol/Downloads/compose-multiplatform-master/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/ImageViewer.ios.kt:15:27 Unresolved reference: launc
e: file:///Users/sol/Downloads/compose-multiplatform-master/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/ImageViewer.ios.kt:16:27 Unresolved reference: withContext
e: file:///Users/sol/Downloads/compose-multiplatform-master/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/ImageViewer.ios.kt:25:18 Unresolved reference: CoroutineScope
e: file:///Users/sol/Downloads/compose-multiplatform-master/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/ImageViewer.ios.kt:25:35 Cannot access class 'kotlinx.coroutines.CoroutineScope'. Check your module classpath for missing or conflicting dependencies
e: file:///Users/sol/Downloads/compose-multiplatform-master/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/ImageViewer.ios.kt:25:60 Cannot access class 'kotlinx.coroutines.CoroutineDispatcher'. Check your module classpath for missing or conflicting dependencies
e: file:///Users/sol/Downloads/compose-multiplatform-master/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/ImageViewer.ios.kt:25:60 Type mismatch: inferred type is CoroutineDispatcher but CoroutineContext was expected
e: file:///Users/sol/Downloads/compose-multiplatform-master/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/ImageViewer.ios.kt:42:30 Unresolved reference: CoroutineScope
e: file:///Users/sol/Downloads/compose-multiplatform-master/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/ImageViewer.ios.kt:55:45 Suspend function 'getNSDataToShare' should be called only from a coroutine or another suspend function
e: file:///Users/sol/Downloads/compose-multiplatform-master/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/ImageViewer.ios.kt:56:21 Unresolved reference: withContext
e: file:///Users/sol/Downloads/compose-multiplatform-master/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/ImageViewer.ios.kt:56:45 Cannot access class 'kotlinx.coroutines.MainCoroutineDispatcher'. Check your module classpath for missing or conflicting dependencies
e: file:///Users/sol/Downloads/compose-multiplatform-master/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/platform.ios.kt:47:39 Cannot access class 'kotlinx.coroutines.CoroutineDispatcher'. Check your module classpath for missing or conflicting dependencies
e: file:///Users/sol/Downloads/compose-multiplatform-master/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/storage/FileExtensions.kt:4:27 Unresolved reference: yield
e: file:///Users/sol/Downloads/compose-multiplatform-master/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/storage/FileExtensions.kt:51:9 Unresolved reference: yield
e: file:///Users/sol/Downloads/compose-multiplatform-master/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/storage/IosImageStorage.ios.kt:11:27 Unresolved reference: CoroutineScope
e: file:///Users/sol/Downloads/compose-multiplatform-master/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/storage/IosImageStorage.ios.kt:14:27 Unresolved reference: launch
e: file:///Users/sol/Downloads/compose-multiplatform-master/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/storage/IosImageStorage.ios.kt:15:27 Unresolved reference: withContext
e: file:///Users/sol/Downloads/compose-multiplatform-master/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/storage/IosImageStorage.ios.kt:39:26 Unresolved reference: CoroutineScope
e: file:///Users/sol/Downloads/compose-multiplatform-master/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/storage/IosImageStorage.ios.kt:100:9 Unresolved reference: withContext
e: file:///Users/sol/Downloads/compose-multiplatform-master/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/storage/IosImageStorage.ios.kt:101:38 Suspension functions can be called only within coroutine body
e: file:///Users/sol/Downloads/compose-multiplatform-master/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/storage/IosImageStorage.ios.kt:105:9 Unresolved reference: withContext
e: file:///Users/sol/Downloads/compose-multiplatform-master/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/storage/IosImageStorage.ios.kt:106:29 Suspension functions can be called only within coroutine body
e: file:///Users/sol/Downloads/compose-multiplatform-master/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/storage/IosImageStorage.ios.kt:109:66 Unresolved reference: withContext
e: file:///Users/sol/Downloads/compose-multiplatform-master/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/storage/IosImageStorage.ios.kt:109:90 Cannot access class 'kotlinx.coroutines.CoroutineDispatcher'. Check your module classpath for missing or conflicting dependencies
e: file:///Users/sol/Downloads/compose-multiplatform-master/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/storage/IosImageStorage.ios.kt:121:11 Suspension functions can be called only within coroutine body

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':shared:compileIosMainKotlinMetadata'.
> Compilation finished with errors

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org/

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 3s
176 actionable tasks: 2 executed, 174 up-to-date
eymar commented 1 year ago

@dima-avdeev-jb It seems this issue is caused by setting the newer coroutines version only for iosMain (other targets transitively depend on coroutines 1.6.4 used in compose)

https://github.com/JetBrains/compose-multiplatform/commit/cbdb0eb69364ff71e28fb75b781d751d76219c2b

Adding the coroutines dependency in commonMain helps.

dima-avdeev-jb commented 1 year ago

Thanks!

eymar commented 1 year ago

Fixed :)

okushnikov commented 3 months ago

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