java.lang.IllegalAccessError: class org.jetbrains.kotlin.kapt3.base.KaptContext cannot access class

Task :app:kaptGenerateStubsDebugKotlin FAILED
e: java.lang.IllegalAccessError: class org.jetbrains.kotlin.kapt3.base.KaptContext (in unnamed module @0x4d1ecff7) cannot access class com.sun.tools.javac.util.Context (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.util to unnamed module @0x4d1ecff7
at org.jetbrains.kotlin.kapt3.base.KaptContext.(KaptContext.kt:28)
at org.jetbrains.kotlin.kapt3.KaptContextForStubGeneration.(KaptContextForStubGeneration.kt:40)
at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.contextForStubGeneration(Kapt3Extension.kt:287)
at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.analysisCompleted(Kapt3Extension.kt:171)
at org.jetbrains.kotlin.kapt3.ClasspathBasedKapt3Extension.analysisCompleted(Kapt3Extension.kt:102)

原因:kapt不兼容JDK 16,17 ,我换成了11,记住是Gladle的jdk版本
降低JDK版本至16以下
Settings -> Gradle 选择jdk11,而非Project Structure->Sdk Location中的jdk版本。
java.lang.IllegalAccessError: class org.jetbrains.kotlin.kapt3.base.KaptContext cannot access class_第1张图片

你可能感兴趣的:(java,kotlin,开发语言)