The app crashes as soon as it gets installed and throws the weird error above. I have annotated the activity as shown below as well as its child fragments.

@AndroidEntryPoint
    class HomeActivity : AppCompatActivity() {
        companion object{
           lateinit var currentUser: User
        }
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
    
            setContentView(R.layout.activity_home)
            val navController = Navigation.findNavController(this, R.id.home_nav)
            val bottomNavigationView: BottomNavigationView = findViewById(R.id.bottom_navigation)
            bottomNavigationView.setupWithNavController(navController)
            fetchCurrentUser()
        }

还附加了Application类,根据文档,使用HILT的每个应用程序都必须附加Application类

@HiltAndroidApp
class CoreApplication:Application()

还有坠机的记录

Caused by: java.lang.IllegalStateException: Hilt Activity must be attached to an @AndroidEntryPoint Application. Found: class androidx.multidex.MultiDexApplication
        at dagger.hilt.android.internal.managers.ActivityComponentManager.createComponent(ActivityComponentManager.java:82)
        at dagger.hilt.android.internal.managers.ActivityComponentManager.generatedComponent(ActivityComponentManager.java:65)
        at com.example.vcare.home.Hilt_HomeActivity.generatedComponent(Hilt_HomeActivity.java:43)
        at com.example.vcare.home.Hilt_HomeActivity.inject(Hilt_HomeActivity.java:62)
        at com.example.vcare.home.Hilt_HomeActivity.onCreate(Hilt_HomeActivity.java:37)
        at com.example.vcare.home.HomeActivity.onCreate(HomeActivity.kt:27)
        at android.app.Activity.performCreate(Activity.java:7224)
        at android.app.Activity.performCreate(Activity.java:7213)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2926)

推荐答案

The solution to this problem was: Declare android:name = ".CoreApplication" in your AndroidManifest.xml file, in the <application .../>tag.

Kotlin相关问答推荐

Kotlin -通过反射获得KProperty 1和CallableReference的实例

同时也是一个字符串的 Kotlin 枚举

generic 类实例列表 - 调用采用 T 的函数

修改器的属性是什么,我需要更改以使角变圆且宽度更小?喷气背包组合

gradle 如何 Select 以-jvm结尾的库?

KMM:编译失败:意外的 IrType 类型:KIND_NOT_SET

嵌套数组 indexOf()

T except one class

Jetpack BottomNavigation - java.lang.IllegalStateException:Already attached to lifecycleOwner

如何为你的 Flutter 元素添加 Kotlin 支持?

Android数据绑定在自定义视图中注入ViewModel

下拉通知面板时是否可以暂停Android中的任何视频(媒体播放器)应用程序?

Kotlin中具有多个参数的绑定适配器

从命令行运行Java到Kotlin转换器?

如何在Kotlin中使方法param可变?

在android的默认浏览器 Select 列表中添加我的浏览器?

Failure delivering result on activity result

Kotlin - 错误:Could not find or load main class _DefaultPackage

Android studio,构建kotlin时出现奇怪错误:生成错误代码

类型推断失败:RecyclerViewActions.scrollTo()