No argument passed with Android Hilt

466 Views Asked by At

I have a fragment:

class PingFragment : Fragment(), ViewRenderer<StartingState> {
    private val viewModel: PingFragmentViewModel by viewModels()

A ViewModel :

class PingFragmentViewModel @ViewModelInject constructor(private var pingRepository: PingRepository) : ViewModel() {

A repository:

@Module
@InstallIn(ActivityComponent::class)
class PingRepository @Inject constructor(@ActivityContext var context: Context) {

When I Start my Application, I have this error:

Caused by: java.lang.InstantiationException: java.lang.Class<com.ping.android.fragment.PingFragmentViewModel> has no zero argument constructor

WHat I can do to tell at Hilt to pass my repo as argument to my VM ?

1

There are 1 best solutions below

0
On BEST ANSWER

You forgot to add @AndroidEntryPoint to your fragment class