// 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
The viewmodel:
Copy code
// In Module B
@HiltViewModel
class FooViewModel @Inject constructor(
private val getFoo: GetFoo
) : ViewModel() { ... }
Tash
01/28/2022, 2:13 AM
Something to do with my setup or could it be a bug?
Tash
01/28/2022, 2:33 AM
Hmm just updated dagger/hilt to 2.40.5, seems to have fixed it 🤔
y
Yves Kalume
01/28/2022, 10:45 AM
Try
hiltViewmodel()
instead of
viewModel()
but first you must add the hilt-compose-navigation lib to your gradle
t
Tash
01/28/2022, 6:39 PM
Had the same result with
hiltViewModel()
… the only thing that fixed it was bumping dagger version 😬