java.lang.Class<ViewModel> has no zero argument constructor
error when using the
hiltViewModel
function. Being stuck on this for over two hours now. I have added all the required libs and annotations but the error won’t go. Any help will be appreciated.
Smorg
08/05/2021, 9:31 PM
It is a multi-module project and was previously working until I moved some modules around, and it just keeps crashing with that error.
c
Colton Idle
08/06/2021, 12:09 AM
Oooh. I had this in the past few weeks. Your activity and fragments all have @AndroidEntryPoint right? That error message is painful because it can be so many things. In my case it was because I was using viewModel() and not hiltViewModel()
s
Smorg
08/06/2021, 2:29 AM
Yes, my activity has the
@AndroidEntryPoint
annotation, and I’m using
hiltViewModel()
. Surprisingly, the entire set up was working perfectly until I just broke down a module into multiple ones, and everything stopped working
Smorg
08/06/2021, 2:30 AM
It is particularly frustrating cos I checked through everything for hours and still can’t get the app to run
Smorg
08/06/2021, 4:27 AM
I restructured my modules again, and it started working 🤦. Still don’t know what the cause is. I just hope it doesn’t happen again.