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

Does compose-jb support ConstraintLayout ? #353

Closed gtf35 closed 3 years ago

gtf35 commented 3 years ago

I can't use ConstraintLayout in latest version: 0.3.0-build150

Did I make a mistake?

image

alialbaali commented 3 years ago

It has been extracted to a different dependency 'androidx.constraintlayout:constraintlayout-compose:1.0.0-alpha01' according to this commit.

gtf35 commented 3 years ago

I see, thanks a lot.

But why I don't need to implement androidx.compose.material:material:1.0.0-alpha11 when I use material widgets(like snackbar)?

gtf35 commented 3 years ago

implementation("androidx.constraintlayout:constraintlayout-compose:1.0.0-alpha01") may cause a lot of problems.

It seems dependent :

Dose compose-jb for desktop need dependent them?

Error log:

Execution failed for task ':compileKotlin'.
> Could not resolve all files for configuration ':compileClasspath'.
   > Could not resolve androidx.compose.ui:ui:1.0.0-alpha11.
     Required by:
         project : > androidx.constraintlayout:constraintlayout-compose:1.0.0-alpha01
      > No matching variant of androidx.compose.ui:ui:1.0.0-alpha11 was found. The consumer was configured to find an API of a library compatible with Java 11, preferably in the form of class files, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' but:
          - Variant 'releaseApiPublication' capability androidx.compose.ui:ui:1.0.0-alpha11 declares an API of a library, and its dependencies declared externally:
              - Incompatible because this component declares a component, with the library elements 'aar' and the consumer needed a component, preferably in the form of class files
              - Other compatible attributes:
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
          - Variant 'releaseRuntimePublication' capability androidx.compose.ui:ui:1.0.0-alpha11 declares a runtime of a library, and its dependencies declared externally:
              - Incompatible because this component declares a component, with the library elements 'aar' and the consumer needed a component, preferably in the form of class files
              - Other compatible attributes:
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
          - Variant 'sourcesElements' capability androidx.compose.ui:ui:1.0.0-alpha11 declares a runtime of a component, and its dependencies declared externally:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
   > Could not resolve androidx.compose.ui:ui-unit:1.0.0-alpha11.
     Required by:
         project : > androidx.constraintlayout:constraintlayout-compose:1.0.0-alpha01
      > No matching variant of androidx.compose.ui:ui-unit:1.0.0-alpha11 was found. The consumer was configured to find an API of a library compatible with Java 11, preferably in the form of class files, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' but:
          - Variant 'releaseApiPublication' capability androidx.compose.ui:ui-unit:1.0.0-alpha11 declares an API of a library, and its dependencies declared externally:
              - Incompatible because this component declares a component, with the library elements 'aar' and the consumer needed a component, preferably in the form of class files
              - Other compatible attributes:
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
          - Variant 'releaseRuntimePublication' capability androidx.compose.ui:ui-unit:1.0.0-alpha11 declares a runtime of a library, and its dependencies declared externally:
              - Incompatible because this component declares a component, with the library elements 'aar' and the consumer needed a component, preferably in the form of class files
              - Other compatible attributes:
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
          - Variant 'sourcesElements' capability androidx.compose.ui:ui-unit:1.0.0-alpha11 declares a runtime of a component, and its dependencies declared externally:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
   > Could not resolve androidx.compose.ui:ui-util:1.0.0-alpha11.
     Required by:
         project : > androidx.constraintlayout:constraintlayout-compose:1.0.0-alpha01
      > No matching variant of androidx.compose.ui:ui-util:1.0.0-alpha11 was found. The consumer was configured to find an API of a library compatible with Java 11, preferably in the form of class files, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' but:
          - Variant 'releaseApiPublication' capability androidx.compose.ui:ui-util:1.0.0-alpha11 declares an API of a library, and its dependencies declared externally:
              - Incompatible because this component declares a component, with the library elements 'aar' and the consumer needed a component, preferably in the form of class files
              - Other compatible attributes:
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
          - Variant 'releaseRuntimePublication' capability androidx.compose.ui:ui-util:1.0.0-alpha11 declares a runtime of a library, and its dependencies declared externally:
              - Incompatible because this component declares a component, with the library elements 'aar' and the consumer needed a component, preferably in the form of class files
              - Other compatible attributes:
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
          - Variant 'sourcesElements' capability androidx.compose.ui:ui-util:1.0.0-alpha11 declares a runtime of a component, and its dependencies declared externally:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
   > Could not resolve androidx.compose.foundation:foundation-layout:1.0.0-alpha11.
     Required by:
         project : > androidx.constraintlayout:constraintlayout-compose:1.0.0-alpha01
      > No matching variant of androidx.compose.foundation:foundation-layout:1.0.0-alpha11 was found. The consumer was configured to find an API of a library compatible with Java 11, preferably in the form of class files, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' but:
          - Variant 'releaseApiPublication' capability androidx.compose.foundation:foundation-layout:1.0.0-alpha11 declares an API of a library, and its dependencies declared externally:
              - Incompatible because this component declares a component, with the library elements 'aar' and the consumer needed a component, preferably in the form of class files
              - Other compatible attributes:
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
          - Variant 'releaseRuntimePublication' capability androidx.compose.foundation:foundation-layout:1.0.0-alpha11 declares a runtime of a library, and its dependencies declared externally:
              - Incompatible because this component declares a component, with the library elements 'aar' and the consumer needed a component, preferably in the form of class files
              - Other compatible attributes:
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
          - Variant 'sourcesElements' capability androidx.compose.foundation:foundation-layout:1.0.0-alpha11 declares a runtime of a component, and its dependencies declared externally:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
   > Could not resolve androidx.compose.foundation:foundation:1.0.0-alpha11.
     Required by:
         project : > androidx.constraintlayout:constraintlayout-compose:1.0.0-alpha01
      > No matching variant of androidx.compose.foundation:foundation:1.0.0-alpha11 was found. The consumer was configured to find an API of a library compatible with Java 11, preferably in the form of class files, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' but:
          - Variant 'releaseApiPublication' capability androidx.compose.foundation:foundation:1.0.0-alpha11 declares an API of a library, and its dependencies declared externally:
              - Incompatible because this component declares a component, with the library elements 'aar' and the consumer needed a component, preferably in the form of class files
              - Other compatible attributes:
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
          - Variant 'releaseRuntimePublication' capability androidx.compose.foundation:foundation:1.0.0-alpha11 declares a runtime of a library, and its dependencies declared externally:
              - Incompatible because this component declares a component, with the library elements 'aar' and the consumer needed a component, preferably in the form of class files
              - Other compatible attributes:
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
          - Variant 'sourcesElements' capability androidx.compose.foundation:foundation:1.0.0-alpha11 declares a runtime of a component, and its dependencies declared externally:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')

* 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.
alialbaali commented 3 years ago

I guess it hasn't been refactored completely yet. I suggest you either wait for the next build or refractor to 0.3.0-build149.

Regarding material dependency, I think it's due the fact that material is a design system and built entirely on compose, unlike navigation, paging and other Android specific dependencies which just adds some extensions on top of the actual Android specific implementation.

Also I think currently Compose is depending on a lot of Android dependencies so refactoring these out makes sense to me.

gtf35 commented 3 years ago

It has the same error when I use constraintlayout-compose:1.0.0-alpha01 with 0.3.0-build149
😢😢😢😢

alialbaali commented 3 years ago

Don't add ConstraintLayout dependency if you downgrade.

igordmn commented 3 years ago

Dose compose-jb for desktop need dependent them?

No, those are original artifacts published by Google. JetBrains published the same artifacts (but with different maven coordinates, and from different commit from androidx-main branch)

So to be able to use constraintlayout-compose you should exclude all androidx.compose dependencies:

configurations {
    "implementation" {
        exclude(group = "androidx.compose.animation")
        exclude(group = "androidx.compose.foundation")
        exclude(group = "androidx.compose.material")
        exclude(group = "androidx.compose.runtime")
        exclude(group = "androidx.compose.ui")
    }
}

See also https://github.com/JetBrains/compose-jb/issues/272#issuecomment-760731693

theapache64 commented 3 years ago

So we can use ConstraintLayout inside compose desktop? :thinking: @gtf35

igordmn commented 3 years ago

So we can use ConstraintLayout inside compose desktop? 🤔 @gtf35

No, only in android target

kcmvp commented 3 years ago

I searched a lot about the topic, unfortunately I can not find any documents about this. Where can we get the full list of components(widgets) not supported in the desktop?

igordmn commented 3 years ago

full list of components(widgets) not supported in the desktop

There is no full list, but if you use any "androidx" library then it will be available only for android:

You can look also at https://developer.android.com/jetpack/compose/libraries. If library depends on android-only library, it will be available only for android.

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.