【发布时间】:2020-11-03 08:31:15
【问题描述】:
我有谷歌这个问题,但结果对我不起作用。
详情如下。
public final class App extends com.zhixin.wedeep.common.BaseApplication implements androidx.lifecycle.LifecycleOwner {
^
// Expected @HiltAndroidApp to have a value. Did you forget to apply the Gradle Plugin?
应用代码。
@HiltAndroidApp
class App : BaseApplication(), LifecycleOwner {
@Inject
lateinit var service: EventService
private val mLifecycleRegistry = LifecycleRegistry(this)
}
这个模块的 gradle 文件。
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-allopen'
apply plugin: 'androidx.navigation.safeargs.kotlin'
apply plugin: 'dagger.hilt.android.plugin'
dependencies {
implementation rootProject.ext.dependencies["hilt-android"]
implementation rootProject.ext.dependencies["hilt-lifecycle-viewmodel"]
kapt rootProject.ext.kapt["hilt-compiler"]
kapt rootProject.ext.kapt["hilt-android-compiler"]
}
谁有想法?谢谢!
【问题讨论】:
-
Kotlin 升级到 1.5.20 后也会出现此问题 (github.com/google/dagger/issues/2684) 在
gradle.properties中添加kapt.use.worker.api=false即可解决问题。 -
由 Kotlin 1.5.21 修复
-
kotlin 升级到
1.5.21后不修复
标签: android dagger-2 dagger-hilt