简体   繁体   English

Hilt Fragments 必须附加到 @AndroidEntryPoint Activity。 找到:class

[英]Hilt Fragments must be attached to an @AndroidEntryPoint Activity. Found: class

Is it mandatory to add @AndroidEntryPoint annotation on all dependent classes like fragment dependent upon activity.是否必须在所有依赖类上添加 @AndroidEntryPoint 注释,例如依赖于活动的片段。 Is there any alternative solution for overcome this exception?是否有任何替代解决方案可以克服此异常?

Just add @AndroidEntryPoint to your parent Activity class:只需将@AndroidEntryPoint添加到您的父Activity class:

在此处输入图像描述

And yes, it's a mandatory process if you want to use Hilt.是的,如果您想使用 Hilt,这是一个强制性的过程。 You could use Dagger to get away with this.你可以使用 Dagger 来解决这个问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Hilt Fragments 必须附加到 @AndroidEntryPoint Activity。 找到:class androidx.fragment.app.testing.FragmentScenario$EmptyFragmentActivity - Hilt Fragments must be attached to an @AndroidEntryPoint Activity. Found: class androidx.fragment.app.testing.FragmentScenario$EmptyFragmentActivity java.lang.IllegalStateException:必须将 Hilt 活动附加到找到的 @AndroidEntryPoint 应用程序:class dv.file.transh.app.FileExplorer - java.lang.IllegalStateException: Hilt Activity must be attached to an @AndroidEntryPoint Application Found: class dv.file.transh.app.FileExplorer Hilt Fragment 必须附加到@AndroidEntryPoint Activity,同时测试(它附加到@AndEntPoint 标记的活动) - Hilt Fragment has to be attached to @AndroidEntryPoint Activity, while testing (it is attached to @AndEntPoint marked activity) Android片段没有活动。 安全丢弃? - Android fragments without an activity. Safe to discard? Dagger-Hilt @AndroidEntryPoint 不适用于 BottomSheetDialogFragment() - Dagger-Hilt @AndroidEntryPoint is not working with BottomSheetDialogFragment() 在多个Fragment中实现相同的接口,从Activity调用。 - Implementing same interface in multiple Fragments, called from Activity. Hilt 创建一个视图 model 实例在 Activity 和它们的片段之间共享 - Hilt Create one view model instance shared between the activity and their fragments 附加到父活动和“后退”按钮的片段 - Fragments attached to a parent activity and back button Dagger - Hilt:我们是否需要用@AndroidEntryPoint 标记所有活动 - Dagger - Hilt : Do we need to mark all activities with @AndroidEntryPoint @AndroidEntryPoint 基类必须扩展 ComponentActivity、(支持)Fragment、View、Service 或 BroadcastReceiver - @AndroidEntryPoint base class must extend ComponentActivity, (support) Fragment, View, Service, or BroadcastReceiver
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM