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.2k stars 1.17k forks source link

all/some functions in package androidx.compose.ui.util don't compile on Android #3095

Closed MikolajKakol closed 1 month ago

MikolajKakol commented 1 year ago

Describe the bug I'm using a template https://github.com/JetBrains/compose-multiplatform-ios-android-template and there adding:

import androidx.compose.ui.util.fastForEach
import androidx.compose.ui.util.fastForEachIndexed
import androidx.compose.ui.util.fastFirstOrNull
import androidx.compose.ui.util.lerp

It will cause code not to compile on the Android target while it is building on iOS. Note that this is also perfectly fine on regular Android projects.

It will fail with errors likeUnresolved reference: util, Unresolved reference: fastFirstOrNull etc

Other things that don't compile:

    Crossfade(
        label = "animation",

rememberInfiniteTransition(label = "loading")

    val translateAnimation by transition.animateFloat(
        label = "loading",

Cannot find a parameter with this name: label

Affected platforms Select one of the platforms below:

Versions

eymar commented 1 year ago

There's defintely an issue that android compilation doesn't work while ios works. But as a workaround adding the dependency explicitly helps:

val commonMain by getting {
            dependencies {
               ....
                implementation(compose.animation)
                implementation("org.jetbrains.compose.ui:ui-util:1.4.0")
            }
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.