当我在项目中使用hilt时,我遇到了这个问题:
A problem occurred evaluating project ':app'.
> Failed to apply plugin 'dagger.hilt.android.plugin'.
> Could not create plugin of type 'HiltGradlePlugin'.
> Could not generate a decorated class for type HiltGradlePlugin.
> com/android/build/gradle/BaseExtension
Run Code Online (Sandbox Code Playgroud)
Unable to load class 'com.android.build.gradle.BaseExtension'.
This is an unexpected error. Please file a bug containing the idea.log file.
Run Code Online (Sandbox Code Playgroud)
主要问题是:无法应用插件“dagger.hilt.android.plugin”。
这是我的 build.gradle(模块)文件:
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
apply plugin: 'kotlin-kapt'
apply plugin: 'dagger.hilt.android.plugin'
android {
compileSdk 30
defaultConfig {
applicationId "net.holosen.hiltdaggerapp"
minSdk 21
targetSdk …Run Code Online (Sandbox Code Playgroud)