我有谷歌这个问题,但结果对我不起作用。
详情如下。
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"]
}
谁有想法?谢谢!
最佳答案
我今天早上刚遇到这个问题。您的 build.gradle 中是否有任何向 annotationProcessOptions 添加参数的内容?例如:
android {
...
defaultConfig {
...
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation":
"$projectDir/schemas".toString()]
}
}
}
}
如果是这样,请尝试从“arguments =”更改为“arguments +=”,因为仅使用 equals 会覆盖之前设置的任何内容。
关于android - 预期 @HiltAndroidApp 具有值。您是否忘记应用 Gradle 插件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62887817/