@AndroidEntryPoint-annotated classes cannot have type parameters.
See original GitHub issue@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
Issue Analytics
- State:
- Created a year ago
- Comments:16
Top Results From Across the Web
<identifier> expected android Hilt - kotlin - Stack Overflow
You can fix this by moving @AndroidEntryPoint from abstract class with parameters into child class without type parameters.
Read more >java/dagger/hilt/android/processor/internal/androidentrypoint ...
"@%s-annotated classes cannot have type parameters.",. annotationClassName.simpleName());. final TypeElement androidEntryPointClassValue = Processors.
Read more >Dependency injection with Hilt | Android Developers
... Work with observable data objects · Generated binding classes · Binding adapters ... Type safe navigation with Compose · Interact programmatically ...
Read more >Migrating to Hilt - Dagger
All @Module classes should be annotated with @InstallIn . ... used to either add inject methods or get access to types like bindings...
Read more >View model has no zero arg constructor when using ...
class ); // crashes ? An activity, a fragment? Is it annotated with @AndroidEntryPoint ? Would be great if you have a sample...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.