Reputation: 795
I have just updated my android Hilt-Dagger dependences to 1.0.0-alpha03
and I figure that ApplicationComponent
is deprecated
and replaced with SingletonComponent
but once I replace it at my code it shows up this error
Am I need to do anything else except replacing it?
Full Error
> 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)
Thanks in advance.
Upvotes: 30
Views: 6911
Reputation: 589
Try updating your hilt-android-compiler to
kapt "com.google.dagger:hilt-android-compiler:2.37"
You're able to import the SingleComponent class, but kapt is failing to process it correctly.
It's important that both the hilt version and the kapt version match. Here is my current setup.
// HILT
def hilt_version = "2.37"
implementation "com.google.dagger:hilt-android:$hilt_version"
kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
Upvotes: 48
Reputation: 505
In my case, adding value to @mikeBlack and @user2343647 answer. Make sure that all the three are updated to same version number. Module level build.gradle
implementation "com.google.dagger:hilt-android:2.36"
kapt "com.google.dagger:hilt-android-compiler:2.36"
and Project level build.gradle
classpath "com.google.dagger:hilt-android-gradle-plugin:2.36"
Replace 2.36 with latest version.
Upvotes: 2
Reputation: 661
This happened to me when Android studio suggested an upgrade of hilt to 2.31 from 2.28. But it did not suggest for the kapt. Make sure both are 2.31.
Upvotes: 6