compose-multiplatform icon indicating copy to clipboard operation
compose-multiplatform copied to clipboard

Update Lifecycle Runtime Compose to 2.8.2

Open blakelee opened this issue 1 year ago • 2 comments
trafficstars

The Jetbrains version of the lifecycle library depends on Android's lifecycle 2.8.0. Version 2.8.2 fixes some annoying issues with the LocalLifecycleOwner. I'm requesting that we update Jetbrains lifecycle to 2.8.2 to match the Android version.

Affected platforms

  • Android (I know the template says to use the Android issue tracker, but this is a Jetbrains issue to update the binary that includes the fix)

Versions

  • Libraries:
    • org.jetbrains.androidx.lifecycle:lifecycle-runtime-compose:2.8.0

Here's the Google issue tracker fix of it https://android-review.googlesource.com/c/platform/frameworks/support/+/3096018

The issue was seen in a standard UI test similar to this https://github.com/square/leakcanary/issues/2677

blakelee avatar Jun 28 '24 23:06 blakelee

but this is a Jetbrains issue to update the binary that includes the fix

We're redirecting original Google's binaries on Android, it allows avoiding conflicts with Android-only libraries and update that part in project independently. Just add a patched Google dependency to your androidMain sourceset.

PS There is 2.8.3 with proper ProGuard rules for that compatibility reflection hack.

MatkovIvan avatar Jun 29 '24 05:06 MatkovIvan

Neat, so if I'm following correctly I can just do something like this? I'm not seeing a 2.8.3 anywhere yet, I'm not as familiar with the android.googlesource.com for finding these things. Hopefully this post will help out others that are struggling with the same issue.

kotlin {
  ...
  sourceSets {
    commonMain.dependencies {
      implementation("org.jetbrains.androidx.lifecycle:lifecycle-runtime-compose:2.8.0")
    }
    androidMain.dependencies {
     implementation("androidx.lifecycle:lifecycle-runtime-compose:2.8.2")
    }
  }
}

Does adding the Android dependencies for other things also work? I'm assuming as long as the Kotlin version and Compose compiler are the same I can just put other updated libraries in androidMain.

blakelee avatar Jun 29 '24 17:06 blakelee

Does adding the Android dependencies for other things also work?

It will work for JetBrains' multiplatform adoptions of compose/lifecycle/navigation. It works because we don't even re-build android and uses redirection to Google's binaries on platforms where supported. Aside of independent applying of patches, it allows using Android-only libraries with these dependencies without issues like "Duplicate class declarations".

MatkovIvan avatar Jul 01 '24 07:07 MatkovIvan

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

okushnikov avatar Jul 14 '24 14:07 okushnikov