【问题标题】:Is ApplicationComponent deprecated?ApplicationComponent 是否已弃用?
【发布时间】:2020-12-12 15:27:51
【问题描述】:

我刚开始在 Android 上使用 Dagger Hilt 进行依赖注入,我在 Android Studio 上收到警告说'ApplicationComponent' is deprecated. Deprecated in Java

我在谷歌搜索时没有找到与此警告相关的任何内容,它实际上已被弃用还是可以安全使用?

我还在 Dagger 的网站上注意到,他们在“Migrating to Hilt”指南中的任何地方都没有提到它,他们使用 @InstallIn(SingletonComponent::class),这似乎有效,但我不知道为什么。

【问题讨论】:

    标签: android dagger dagger-hilt


    【解决方案1】:

    ApplicationComponent 被重命名为 SingletonComponent,以允许在非 Android Gradle 模块中使用 Hilt link

    【讨论】:

    • 非常感谢 :)
    【解决方案2】:

    ApplicationComponent 是否已弃用?

    是的,它已被弃用。

    您可以使用SingletonComponent,而不是ApplicationComponent。 这是用于单例绑定的 Hilt 组件

    【讨论】:

      猜你喜欢
      • 2023-03-08
      • 2018-09-12
      • 2017-12-06
      • 2017-08-11
      • 1970-01-01
      • 1970-01-01
      • 2017-11-16
      • 2011-07-30
      • 1970-01-01
      相关资源
      最近更新 更多