Dagger Hilt doesn't work with Dynamic Feature Modules.
See original GitHub issueVersions:
- Dagger 2.28
- Dagger Hilt 2.28-alpha
I tried Dagger Hilt with Dynamic Feature Modules. Here is a sample project: https://github.com/yamasa/Hilt_DFM
But, unfortunately, Dagger Hilt doesn’t work for Activities in DFM. It crashes with the following exception:
Caused by: java.lang.ClassCastException: com.example.hilt_dfm.DaggerMyApplication_HiltComponents_ApplicationC$ActivityRetainedCImpl$ActivityCImpl cannot be cast to com.example.hilt_dfm.feature.DfmActivity_GeneratedInjector
at com.example.hilt_dfm.feature.Hilt_DfmActivity.inject(Hilt_DfmActivity.java:60)
at com.example.hilt_dfm.feature.Hilt_DfmActivity.onCreate(Hilt_DfmActivity.java:35)
at com.example.hilt_dfm.feature.DfmActivity.onCreate(DfmActivity.kt:17)
at android.app.Activity.performCreate(Activity.java:7825)
...
Does Dagger Hilt currently support Dynamic Feature Modules? If not, is there a plan to support it?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:14
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Dynamic feature module with Hilt · Issue #2758 · google/dagger
I try to make my feature module as a dynamic feature module while I am using Hilt as dependency injection framework.
Read more >Dynamic feature module with Hilt - Stack Overflow
As mentioned in the following link : Dagger Hilt doesn't work with Dynamic Feature Modules : Hilt uses a monolithic component system which ......
Read more >Hilt and Jetpack integrations in the Dynamic Feature world.
Migrating your Dagger app to Hilt. But we have very few articles on how to work with Hilt in the Dynamic Feature world....
Read more >Hilt in multi-module apps - Android Developers
Therefore, Hilt cannot process annotations in feature modules. You must use Dagger to perform dependency injection in your feature modules. You ...
Read more >Android — Clean architecture with Dynamic-features and Hilt ...
According to Google, it is still not possible to use Hilt on dynamic feature modules and the suggested approach is to use Dagger....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
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
There’s documentation on Hilt and DFM now at https://developer.android.com/training/dependency-injection/hilt-multi-module#dfm
In general though, because we’re built off of subcomponents and monolithic components you won’t be able to use the standard Hilt mechanisms like
@AndroidEntryPoint
with DFM.Thank you. I’m really looking forward to it!