ApplicationComponent 是否已弃用?
Is ApplicationComponent deprecated?
我刚开始在 Android 上使用 Dagger Hilt 进行依赖项注入,我在 Android Studio 上收到一条警告说 'ApplicationComponent' is deprecated. Deprecated in Java
。
我在谷歌搜索时没有发现与此警告相关的任何内容,它实际上已被弃用还是可以安全使用?
我还在 Dagger 的网站上注意到,他们在“Migrating to Hilt”指南的任何地方都没有提到它,他们使用的 @InstallIn(SingletonComponent::class)
似乎有效,但我不知道为什么。
ApplicationComponent
重命名为 SingletonComponent
,以允许在非 Android Gradle 模块 link
中使用 Hilt
Is ApplicationComponent deprecated?
是的,它已被弃用。
您可以使用 SingletonComponent
而不是 ApplicationComponent
。
这是单例绑定的 Hilt 组件
替换为@InstallIn(SingletonComponent :: class)
它会起作用
我刚开始在 Android 上使用 Dagger Hilt 进行依赖项注入,我在 Android Studio 上收到一条警告说 'ApplicationComponent' is deprecated. Deprecated in Java
。
我在谷歌搜索时没有发现与此警告相关的任何内容,它实际上已被弃用还是可以安全使用?
我还在 Dagger 的网站上注意到,他们在“Migrating to Hilt”指南的任何地方都没有提到它,他们使用的 @InstallIn(SingletonComponent::class)
似乎有效,但我不知道为什么。
ApplicationComponent
重命名为 SingletonComponent
,以允许在非 Android Gradle 模块 link
Is ApplicationComponent deprecated?
是的,它已被弃用。
您可以使用 SingletonComponent
而不是 ApplicationComponent
。
这是单例绑定的 Hilt 组件
替换为@InstallIn(SingletonComponent :: class) 它会起作用