Tash
01/28/2022, 2:11 AMhas no zero argument constructor
runtime error when using androidx.lifecycle.viewmodel.compose.viewModel()
🧵ViewModel
is in a separate gradle module// In Module A
@AndroidEntryPoint
class FooActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
// Breaks when FooViewModel is in a different gradle module
val fooViewModel = viewModel<FooViewModel>()
ScreenContent(state = fooViewModel.state)
}
}
}
// In Module B
@HiltViewModel
class FooViewModel @Inject constructor(
private val getFoo: GetFoo
) : ViewModel() { ... }
Yves Kalume
01/28/2022, 10:45 AMhiltViewmodel()
instead of viewModel()
but first you must add the hilt-compose-navigation lib to your gradleTash
01/28/2022, 6:39 PMhiltViewModel()
… the only thing that fixed it was bumping dagger version 😬