Closed Jeff11 closed 3 years ago
Did you forget to apply the Gradle Plugin (dagger.hilt.android.plugin)?
I am using the Gradle plugin. Until Kotlin 1.5.10 there are no problems with the build. It just started with 1.5.20-M1 and -RC.
I can switch to 1.5.10 and the build will work.
i also have this issue and @jeff11 is rith its working fine with 1.5.10
Also with 1.5.20-RC not working compiler argument for disabling InstallIn check:
javaCompileOptions {
annotationProcessorOptions {
arguments += [
"dagger.hilt.disableModulesHaveInstallInCheck": "true"
]
}
}
This sounds like a bug in the kotlin/kapt plugin rather than Hilt. In particular, javaCompilerOptions.annotationProcessorOptions
are just getting ignored in general, as mentioned in https://github.com/google/dagger/issues/2684#issuecomment-860175674. This ends up causing Hilt to fail because the Hilt Gradle plugin sets these options in HiltGradlePlugin.kt.
FWIW, it looks like the processing options set through kapt.javacOptions
do still work, so as a workaround you can set the options manually:
kapt {
javacOptions {
// These options are normally set automatically via the Hilt Gradle plugin, but we
// set them manually to workaround a bug in the Kotlin 1.5.20
option("-Adagger.fastInit=ENABLED")
option("-Adagger.hilt.android.internal.disableAndroidSuperclassValidation=true")
}
}
kapt.use.worker.api=false fixes many strange issues from kapt
I've filed a bug with kotlin here: https://youtrack.jetbrains.com/issue/KT-47416
kapt.use.worker.api=false fixes many strange issues from kapt
It'll decrease build speed though: https://kotlinlang.org/docs/kapt.html#improving-the-speed-of-builds-that-use-kapt
To improve the speed of builds that use kapt, you can enable the Gradle worker API for kapt tasks. Using the worker API lets Gradle run independent annotation processing tasks from a single project in parallel, which in some cases significantly decreases the execution time.
@bcorso sulution works. 👍
Kotlin 1.5.21 fixes the issue for me https://github.com/JetBrains/kotlin/releases/tag/v1.5.21
With Kotlin 1.5.20-RC I get this error.
Works with Kotlin 1.5.10.
Dagger version 2.37