当我使用Hilt作为依赖注入框架时,我尝试将我的功能模块作为一个动态功能模块。我收到以下异常:
caused by: java.lang.ClassCastException: com.android.sample.viaplay.DaggerViaplayApplication_HiltComponents_SingletonC$ActivityRetainedCImpl$ActivityCImpl$FragmentCI cannot be cast to com.android.sample.viaplay.feature.list.ui.DashboardFragment_GeneratedInjector
at com.android.sample.viaplay.feature.list.ui.Hilt_DashboardFragment.inject(Hilt_DashboardFragment.java:104)
at com.android.sample.viaplay.feature.list.ui.Hilt_DashboardFragment.onAttach(Hilt_DashboardFragment.java:55)
at androidx.fragment.app.Fragment.onAttach(Fragment.java:1783)
at com.android.sample.viaplay.feature.list.ui.Hilt_DashboardFragment.onAttach(Hilt_DashboardFragment.java:43)我在另一个示例中使用了Dagger而不是Dagger-Hilt,它的工作效果与预期一致:https://github.com/AliRezaeiii/DFM-MultiModule-Cache
可以在Hilt中使用动态功能模块吗?如果是,我如何解决上述异常。您可以在以下位置找到我的源代码:https://github.com/AliRezaeiii/Hilt-MultiModule-Cache
发布于 2021-07-24 22:18:57
如以下链接所述:Dagger Hilt doesn't work with Dynamic Feature Modules:
Hilt使用与动态装入类的DFM不兼容的单片组件系统。
https://stackoverflow.com/questions/68444389
复制相似问题