sebaslogen / resaca

Compose Multiplatform library to scope ViewModels to a Composable, surviving configuration changes and navigation
MIT License
427 stars 10 forks source link

Resaca pulls in unstable version of Compose runtime #133

Closed mlewandowskipt closed 1 month ago

mlewandowskipt commented 2 months ago

Affected version: 4.1.3, probably also earlier ones

Steps to reproduce:

  1. Have project with stable version of Compose set up
  2. Add resaca
  3. Run ./gradlew :app:dependencies > out

In output you can see that resaca adds unstable version of Compose runtime:

|    +--- io.github.sebaslogen:resaca:4.1.3
|    |    \--- io.github.sebaslogen:resaca-android:4.1.3
|    |         \--- org.jetbrains.compose.runtime:runtime:1.7.0-alpha03
|    |              +--- androidx.compose.runtime:runtime:1.7.0-beta06 (*)

which replaces stable version added to the project, possibly resulting in some hard-to-track incompatibilities:

+--- project :some-module
|    +--- androidx.compose.ui:ui -> 1.6.8 (*)
|    +--- androidx.compose.runtime:runtime -> 1.7.0-beta06 (*)
sebaslogen commented 2 months ago

That's the side effect of supporting Compose multiplatform (since version 4.0.0 of resaca), only version 1.7.0+ of Compose Multiplatform supports the multiplatform lifecycle artifacts required for ViewModels.

If you want to use stable Compose and you don't care about multiplatform you can stick to resaca 3.3.7 for the time being. The majority of the features and fixes introduced since then are all related to Compose Multiplatform.

As soon as Compose Multiplatform 1.7.0 is stable I would keep this library on stable releases of Compose for both native Android and Multiplatform.

mlewandowskipt commented 2 months ago

Ok but does it actually make sense to add multiplatform dependency to the resaca-android artifact? Maybe there should be explicit resaca-multiplatform artifact that depends on multiplatform libraries? My project is pure Android so it doesn't need Compose Multiplatform runtime. For now I will exclude it by having something like

configurations.all {
    exclude(group = "org.jetbrains.compose.runtime", module = "runtime")
}

but it's kind of a workaround.

sebaslogen commented 2 months ago

Ok but does it actually make sense to add multiplatform dependency to the resaca-android artifact? Maybe there should be explicit resaca-multiplatform artifact that depends on multiplatform libraries? My project is pure Android so it doesn't need Compose Multiplatform runtime. For now I will exclude it by having something like

configurations.all {
    exclude(group = "org.jetbrains.compose.runtime", module = "runtime")
}

but it's kind of a workaround.

Thanks for the suggestion, that's actually how the multiplatform feature started in early proof of concepts but I soon realized that a separate artifact would complicate a lot packaging and testing with potentially different versions of Compose, lifecycle and ViewModel libraries per resaca artifact.

I apologize for the inconvenience. Your workaround should be as good as staying with version 3.3.7 for Android-only projects.

mlewandowskipt commented 2 months ago

Actually excluding Compose Multiplatform runtime resulted in

java.lang.NoSuchMethodError: No interface method startReplaceGroup(I)V in class Landroidx/compose/runtime/Composer; or its super classes (declaration of 'androidx.compose.runtime.Composer' appears in /data/app/~~NnMAa01zYOFCIoqSOmn7Mw==/com.myapp-a79RJAaUiG_IAD3mVWB80g==/base.apk)

even though I have AndroidX Runtime 1.6.8 bundled within the app so I'll just downgrade to 3.3.7

sebaslogen commented 2 months ago

To continue supporting Compose stable in this library until the Compose Multiplatform team makes a new release with support for Compose stable, I will continue to support the 3.x version of resaca and backport any important feature or bugfix from the 4.x branches to the 3.x one.

To put that into action, I backported fix in PR138 from 4.1.4 to 3.3.8

Once the 4.x releases contain a Compose stable release I will close this ticket.

sebaslogen commented 1 month ago

Resolved in release 4.3.2, this includes stable versions of Compose for Android included in Compose multiplatform, see release notes.