首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SingletonComponent缺少父声明

SingletonComponent缺少父声明
EN

Stack Overflow用户
提问于 2021-02-05 00:46:34
回答 3查看 6.1K关注 0票数 30

我刚刚将我的android Hilt依赖项更新为1.0.0-字母03。

我认为ApplicationComponent废弃的

代之以SingletonComponent

但是,一旦我在代码中替换了它,它就会显示出这个错误,除了替换它之外,我还需要做什么吗?

全误差

代码语言:javascript
复制
> 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)

提前谢谢。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2021-02-05 03:30:39

尝试将hilt android编译器更新为

kapt "com.google.dagger:hilt-android-compiler:2.37"

您可以导入SingleComponent类,但是kapt未能正确地处理它。

重要的是,两者的刀柄版本和kapt版本相匹配。这是我目前的设置。

代码语言:javascript
复制
// HILT
def hilt_version = "2.37"
implementation "com.google.dagger:hilt-android:$hilt_version"
kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
票数 47
EN

Stack Overflow用户

发布于 2021-04-02 12:36:06

当Android工作室建议将hilt从2.28升级到2.31时,我就遇到了这种情况。但这并不意味着凯普特。确保两者都是2.31。

票数 6
EN

Stack Overflow用户

发布于 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。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66056031

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档