Chris B
08/11/2024, 5:32 AMChris B
08/11/2024, 5:32 AMType 'androidx.compose.runtime.State<puzzles.PuzzlesState>' has no method 'getValue(Nothing?, KProperty0<*>)', so it cannot serve as a delegate.
hfhbd
08/11/2024, 5:58 AMChris B
08/11/2024, 6:04 AMgetValue
import?Chris B
08/11/2024, 6:04 AMhfhbd
08/11/2024, 6:05 AMChris B
08/11/2024, 6:05 AMhfhbd
08/11/2024, 6:06 AMby
hfhbd
08/11/2024, 6:07 AMval
, you only need the getValue, otherwise you need the write method (setValue) toohfhbd
08/11/2024, 6:07 AMChris B
08/11/2024, 6:13 AMChris B
08/11/2024, 6:14 AMChris B
08/11/2024, 6:15 AMChris B
08/11/2024, 6:15 AMhfhbd
08/11/2024, 6:20 AMChris B
08/11/2024, 6:21 AMChris B
08/11/2024, 7:04 AMimport androidx.lifecycle.viewmodel.compose.viewModel
@Composable
fun GameScreen(
gameViewModel: GameViewModel = viewModel()
) {
// ...
}
Chris B
08/11/2024, 7:04 AMviewModel
function. The import fails.Chris B
08/11/2024, 7:06 AMRamitsuri007
08/11/2024, 10:04 AMimplementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1")
which needs to be included in step 5
https://developer.android.com/codelabs/basic-android-kotlin-compose-viewmodel-and-state#4Chris B
08/11/2024, 10:15 AMandroidx-lifecycle = { group = "androidx.lifecycle", name="lifecycle-viewmodel-compose", version.ref = "androidx-lifecycle" }
defined in my build, at version 2.8.4