在项目build.gradle文件中为Kotlin添加插件,并将其设置为JDK 11。示例如下:
buildscript {
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"
}
}
plugins {
id 'org.jetbrains.kotlin.kapt' version '1.5.21'
}
android {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
}
dependencies {
...
kapt "com.google.dagger:hilt-android-compiler:2.38.1"
}