在使用Jectpack的Hilt的时候编译报错:Expected @HiltAndroidApp to have a value. Did you forget to apply the Gradle Plugin?百度了半天都说要配置下面的内容
在这里插入图片描述
重新编译发现并不好使。后来在StackOverflow找到了答案,只需要将Kotlin 升级到1.5.21就可以了,可能是以前版本的Kotlin 不兼容Hilt的问题,特此记录一下。
StackOverflow连接地址

dependencies {
        classpath "com.android.tools.build:gradle:7.0.3"
           ---------就是下面Kotlin的版本--------
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"
        classpath "com.google.dagger:hilt-android-gradle-plugin:2.28-alpha"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐