Hello, for `nav3` in a Compose Multiplatform proje...
# multiplatform
g
Hello, for
nav3
in a Compose Multiplatform project, did anyone manage to use the new
org.jetbrains.androidx.lifecycle:lifecycle-viewmodel-navigation3
artifact so that we can use
rememberViewModelStoreNavEntryDecorator()
to scope a ViewModel to the composable in the backstack? I tried many versions, latest I tried is
Copy code
compose-multiplatform = "1.10.0-alpha03+dev3110"
navigation3-runtime = "1.0.0+dev2861"
navigation3-ui = "1.0.0-alpha03+dev3110"
navigation3-viewmodel = "2.10.0-alpha03+dev3110"
Basically, the IDE lets me import the library, but when building I get errors like the library is not even present:
Copy code
> Task :features:categories:compileDebugKotlinAndroid
e: (...)/features/categories/navigation/CategoriesNavEntries.kt:6:37 Unresolved reference 'EntryProviderBuilder'.
e: (...)/features/categories/navigation/CategoriesNavEntries.kt:8:37 Unresolved reference 'entry'.
e: (...)/features/categories/navigation/CategoriesNavEntries.kt:28:5 Unresolved reference 'EntryProviderBuilder'.
e: (...)/features/categories/navigation/CategoriesNavEntries.kt:32:5 Unresolved reference 'entry'.
e: (...)/features/categories/navigation/CategoriesNavEntries.kt:32:29 Cannot infer type for value parameter 'chooseCategory'. Specify it explicitly.
e: (...)/features/categories/navigation/CategoriesNavEntries.kt:34:50 @Composable invocations can only happen from the context of a @Composable function
e: (...)/features/categories/navigation/CategoriesNavEntries.kt:35:42 @Composable invocations can only happen from the context of a @Composable function
e: (...)/features/categories/navigation/CategoriesNavEntries.kt:37:9 @Composable invocations can only happen from the context of a @Composable function
e: (...)/features/categories/navigation/CategoriesNavEntries.kt:45:5 Unresolved reference 'entry'.
e: (...)/features/categories/navigation/CategoriesNavEntries.kt:45:32 Cannot infer type for value parameter 'chooseSubCategory'. Specify it explicitly.
e: (...)/features/categories/navigation/CategoriesNavEntries.kt:47:53 @Composable invocations can only happen from the context of a @Composable function
e: (...)/features/categories/navigation/CategoriesNavEntries.kt:47:100 Unresolved reference 'categoryType'.
e: (...)/features/categories/navigation/CategoriesNavEntries.kt:48:42 @Composable invocations can only happen from the context of a @Composable function
e: (...)/features/categories/navigation/CategoriesNavEntries.kt:50:9 @Composable invocations can only happen from the context of a @Composable function
What am I missing? 🤔
🧵 1
z
You probably want to replace
EntryProviderBuilder
with
EntryProviderScope
, it was renamed in newer versions. I assume the other errors are fixed by this change from here. I have a working usage of the new library in this commit/PR, though the code overall is still draft quality (so don't take it as an exact sample necessarily) https://github.com/JetBrains/kotlinconf-app/pull/504/commits/50557adc4bcae06357fcb7254d8a1d1e956d4eec
🔥 4
❤️ 1
g
You rock @zsmb, thank you!!! I had an issue (after renaming the class and all its usages) of a double runtime artifact somehow till I saw that you removed its dependency, and only then it finally worked! Thanks again 😊
z
Glad to hear it's working now! 🎉
❤️ 1