Tash
01/28/2022, 2:11 AMhas no zero argument constructor runtime error when using androidx.lifecycle.viewmodel.compose.viewModel() 🧵Tash
01/28/2022, 2:12 AMViewModel is in a separate gradle moduleTash
01/28/2022, 2:12 AM// 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)
}
}
}Tash
01/28/2022, 2:12 AM// In Module B
@HiltViewModel
class FooViewModel @Inject constructor(
private val getFoo: GetFoo
) : ViewModel() { ... }Tash
01/28/2022, 2:13 AMTash
01/28/2022, 2:33 AMYves 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 😬