I'm trying to use a single factory for creating ViewModels with constructor parameters. I followed the recommendation in one of the open dagger issues by @matejdro https://github.com/google/dagger/issues/1273
But the injection doesn't work.
I"m getting an error:"error: [Dagger/MissingBinding] kotlin.Lazy cannot be provided without an @Provides-annotated method."
Any idea how to resolve the issue? I uploaded my created project to github: https://github.com/davida5/daggerViewModelBestPractice
That's pretty simple, you should be using dagger.Lazy
(include an import for it) instead of the kotlin.Lazy
Once that is fixed you will run into another issue though; AFAIK you can't use a qualified dependency without a corresponding qualified provider. You have a qualified UserManager
instance being injected into AccountsViewModel
. Either add a qualified provider method or remove the qualification from the AccountsViewModel
.