作者:lyw | 来源:互联网 | 2023-06-19 10:05
我刚开始在 Android 上使用 Dagger Hilt 进行依赖注入,我在 Android Studio 上收到一条警告说'ApplicationComponent' is deprecated.
我刚开始在 Android 上使用 Dagger Hilt 进行依赖注入,我在 Android Studio 上收到一条警告说'ApplicationComponent' is deprecated. Deprecated in Java
.
我在谷歌搜索时没有找到与此警告相关的任何内容,它实际上已被弃用还是使用安全?
我还在 Dagger 的网站上注意到他们没有在“迁移到刀柄”指南中的任何地方提及它,他们使用的@InstallIn(SingletonComponent::class)
似乎有效,但我不知道为什么。
回答
ApplicationComponent
重命名为SingletonComponent
,以允许在非 Android Gradle 模块中使用 Hilt链接
回答
不推荐使用 ApplicationComponent 吗?
是的,它已被弃用。
相反ApplicationComponent
,您可以使用SingletonComponent
. 这是用于单例绑定的 Hilt 组件