是否已弃用ApplicationComponent? [英] Is ApplicationComponent deprecated?

查看:127
本文介绍了是否已弃用ApplicationComponent?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用Dagger Hilt在Android上进行依赖项注入,并且在Android Studio上收到一条警告,提示已弃用'ApplicationComponent'.在Java中已弃用.

I just started using Dagger Hilt for dependency injection on Android and I get a warning on Android Studio saying 'ApplicationComponent' is deprecated. Deprecated in Java.

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

I didn't find anything related to this warning while Googling, is it actually deprecated or is it safe to use?

我还在Dagger的网站上注意到,他们在"迁移到Hilt的任何地方都没有提及它"指南,他们使用 @InstallIn(SingletonComponent :: class)似乎有效,但我不知道为什么.

I also noticed on Dagger's website that they don't mention it anywhere in the "Migrating to Hilt" guide and they use @InstallIn(SingletonComponent::class) which seems to be working but I have no idea why.

推荐答案

ApplicationComponent 重命名为 SingletonComponent ,以允许在非Android Gradle模块中使用Hilthref ="https://github.com/google/dagger/releases/tag/dagger-2.28.2" rel ="noreferrer">链接

ApplicationComponent being renamed to SingletonComponent, to allow usage of Hilt in non-Android Gradle modules link

这篇关于是否已弃用ApplicationComponent?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆