我刚刚将我的android Hilt依赖项更新为1.0.0-字母03。
我认为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)提前谢谢。
发布于 2021-02-05 03:30:39
尝试将hilt android编译器更新为
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"发布于 2021-04-02 12:36:06
当Android工作室建议将hilt从2.28升级到2.31时,我就遇到了这种情况。但这并不意味着凯普特。确保两者都是2.31。
发布于 2021-05-27 12:17:31
在我的例子中,将值添加到@mikeBlack和@ answer 2343647答案。确保这三个版本都更新为相同的版本号。模块级build.gradle
implementation "com.google.dagger:hilt-android:2.36"
kapt "com.google.dagger:hilt-android-compiler:2.36"
和项目级build.gradle
classpath "com.google.dagger:hilt-android-gradle-plugin:2.36"
用最新版本取代2.36。
https://stackoverflow.com/questions/66056031
复制相似问题