Skip to content

Broken API after updating KMP ViewModels to 2.9.0 #540

@faogustavo

Description

@faogustavo

When using the KMP ViewModels (org.jetbrains.androidx.lifecycle:lifecycle-viewmodel-compose) version 2.9.0, it uses the SavedState (androidx.savedstate:savedstate) version 1.3.0, which has breaking changes with 1.2.0. Using ViewModel 2.8.4 still works fine.

Error

java.lang.NoSuchMethodError: 'void androidx.savedstate.SavedStateRegistryController.performRestore(androidx.core.bundle.Bundle)'
	at cafe.adriel.voyager.jetpack.VoyagerLifecycleKMPOwner.onCreate(VoyagerLifecycleKMPOwner.kt:90)
	at cafe.adriel.voyager.jetpack.VoyagerLifecycleKMPOwner.LifecycleDisposableEffect$voyager_lifecycle_kmp(VoyagerLifecycleKMPOwner.kt:172)
	at cafe.adriel.voyager.jetpack.ScreenLifecycleKMPOwner$ProvideBeforeScreenContent$1.invoke(ScreenLifecycleJetpackOwner.kt:21)
	at cafe.adriel.voyager.jetpack.ScreenLifecycleKMPOwner$ProvideBeforeScreenContent$1.invoke(ScreenLifecycleJetpackOwner.kt:20)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.kt:121)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.kt:51)
	at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:384)
	at androidx.compose.runtime.saveable.SaveableStateHolderImpl.SaveableStateProvider(SaveableStateHolder.kt:79)

Ideas

I noticed some changes in the public API parameters:

Saved State 1.3.0 - https://github.com/JetBrains/compose-multiplatform-core/blob/jb-main/savedstate/sa[…]/androidx/savedstate/SavedStateRegistryController.nonAndroid.kt

Saved State 1.2.0 - https://github.com/JetBrains/compose-multiplatform-core/blob/6ff110c6f6a7635ab89a7[…]Main/kotlin/androidx/savedstate/SavedStateRegistryController.kt

Reproducer

https://github.com/faogustavo/VoyagerIssueReproducer

To reproduce the problem, just run the tests from the ComposeAppCommonTest class.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions