Is ApplicationComponent deprecated?

六眼飞鱼酱① 提交于 2021-02-08 14:05:36

问题


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?

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.


回答1:


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




回答2:


Is ApplicationComponent deprecated?

Yes, it is deprecated.

Instead of ApplicationComponent, you can use SingletonComponent. This is an Hilt component for singleton bindings



来源:https://stackoverflow.com/questions/65266636/is-applicationcomponent-deprecated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!