dagger: @AndroidEntryPoint-annotated classes cannot have type parameters.
@AndroidEntryPoint abstract class BaseFragment<VM : ViewModel, viewBinding : ViewDataBinding, repository : BaseRepository> : Fragment() { protected lateinit var binding: viewBinding protected lateinit var viewModel: VM var remoteDataSource = RemoteDataSource() ..................................... }
the error code
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 16
This solves the compile error for me. But if I remove
@AndroidEntryPoint
from base class, the @Inject fields in base class will NOT BE SET. Is it a known issue? Do we have plan to support it?It’s a valid cases where both base class and child class have injected fields.
I initially concluded that this wasn’t possible (https://github.com/google/dagger/issues/2042#issuecomment-673252618) since we couldn’t implement the
inject()
method. However, thinking about it more we can probably support it similar to the workaround I suggested above as long as the generic base class is abstract.In particular, the generated
Hilt_MiddleView
class wouldn’t actually implementinject()
, it would just add the abstractinject()
method and the constructor call for you, just like you’re currently doing manually.I think this should be a pretty easy thing for us to fix.
I have tried this solution was still have problems.