question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dagger Hilt doesn't work with Dynamic Feature Modules.

See original GitHub issue

Versions:

  • 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:closed
  • Created 3 years ago
  • Reactions:14
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
Chang-Ericcommented, Jun 10, 2020

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.

3reactions
yamasacommented, Jun 2, 2020

Thank you. I’m really looking forward to it!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found