https://kotlinlang.org logo
#compose-wear
Title
# compose-wear
a

Austin Nelson

12/14/2021, 1:58 AM
After upgrading
androidx.hilt:hilt-navigation-compose
to
1.0.0-beta01
I am now getting this error:
You cannot access the NavBackStackEntry's ViewModels until it is added to the NavController's back stack (i.e., the Lifecycle of the NavBackStackEntry reaches the CREATED state).
But I commented out all of my ViewModel stuff and it's still erroring out. Can anyone explain what changed? This is basically all I have:
Copy code
SwipeDismissableNavHost(
    navController = navController,
    startDestination = "start",
    modifier = Modifier.background(MaterialTheme.colors.background)
) {

    composable("start") {
//                val mainViewModel = hiltViewModel<MainViewModel>()
//                val uiState = mainViewModel.uiState.collectAsState()

        Box(
            modifier = Modifier.fillMaxSize(),
            contentAlignment = Alignment.Center
        ) {
            Text("uiState.value")
        }
    }
}
👍 1
i

Ian Lake

12/14/2021, 2:09 AM
That sounds like this issue, which is already fixed for the next release: https://issuetracker.google.com/issues/207328687
👍 2
👍🏽 1
👍🏻 1
a

Austin Nelson

12/14/2021, 2:11 AM
Thanks! Didn't see that
19 Views