gpt4 book ai didi

android - SingletonComponent 缺少父声明

转载 作者:行者123 更新时间:2023-12-03 13:25:09 29 4
gpt4 key购买 nike

我刚刚更新了我的安卓刀柄 Dagger 对 1.0.0-alpha03 的依赖
我认为 ApplicationComponent 已弃用
并替换为 SingletonComponent
但是一旦我在我的代码中替换它,它就会显示这个错误
除了更换它,我还需要做其他事情吗?
完全错误

> Task :app:kaptDebugKotlin FAILED
error: [Hilt]
@DefineComponent dagger.hilt.components.SingletonComponent is missing a parent declaration.
Please declare the parent, for example: @DefineComponent(parent = ApplicationComponent.class)
[Hilt] Processing did not complete. See error above for details.error: [Hilt]
@DefineComponent dagger.hilt.components.SingletonComponent is missing a parent declaration.
Please declare the parent, for example: @DefineComponent(parent = ApplicationComponent.class)
[Hilt] Processing did not complete. See error above for details.error: [Hilt]
@DefineComponent dagger.hilt.components.SingletonComponent is missing a parent declaration.
Please declare the parent, for example: @DefineComponent(parent = ApplicationComponent.class)
[Hilt] Processing did not complete. See error above for details.error: [Hilt]
@DefineComponent dagger.hilt.components.SingletonComponent is missing a parent declaration.
[Hilt]

Please declare the parent, for example: @DefineComponent(parent = ApplicationComponent.class)
[Hilt] Processing did not complete. See error above for details.

Execution failed for task ':app:kaptDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
> java.lang.reflect.InvocationTargetException (no error message)
提前致谢。

最佳答案

尝试将您的 hilt-android-compiler 更新为kapt "com.google.dagger:hilt-android-compiler:2.37"您可以导入 SingleComponent 类,但 kapt 无法正确处理它。
刀柄版本和 kapt 版本匹配很重要。这是我目前的设置。

// HILT
def hilt_version = "2.37"
implementation "com.google.dagger:hilt-android:$hilt_version"
kapt "com.google.dagger:hilt-android-compiler:$hilt_version"

关于android - SingletonComponent 缺少父声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66056031/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com