期望@HiltAndroidApp具有一个值。您是否忘记了应用Gradle插件? [英] Expected @HiltAndroidApp to have a value. Did you forget to apply the Gradle Plugin?

查看:1739
本文介绍了期望@HiltAndroidApp具有一个值。您是否忘记了应用Gradle插件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Google这个问题,但结果对我来说不起作用。

I have Google this problem, but the results are not work for me.

详细信息如下。

    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文件。

This module gradle file.

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中?例如:

I just hit this problem this morning. Do you have anything in your build.gradle that adds arguments to the annotationProcessOptions? For example:

  android {
        ...
        defaultConfig {
            ...
            javaCompileOptions {
                annotationProcessorOptions {
                    arguments = ["room.schemaLocation":
                                 "$projectDir/schemas".toString()]
                }
            }
        }
    }

如果是这样,请尝试从 arguments =更改为转换为参数+ =,因为仅使用equals会覆盖先前设置的任何内容。

If so, try changing from "arguments =" to "arguments +=", as just using equals overwrites anything set previously.

这篇关于期望@HiltAndroidApp具有一个值。您是否忘记了应用Gradle插件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆