发布于 1年前

Gradle报错:KotlinReflectionNotSupportedError: Kotlin reflection implementation is not found at runtime. Make sure you have kotlin-reflect.jar in the classpath

基于Gradle和Kotlin开发的项目,gradle运行项目是报错:

Exception in thread "main" kotlin.jvm.KotlinReflectionNotSupportedError: Kotlin reflection implementation is not found at runtime. Make sure you have kotlin-reflect.jar in the classpath
    at kotlin.jvm.internal.ClassReference.error(ClassReference.kt:86)
    at kotlin.jvm.internal.ClassReference.getQualifiedName(ClassReference.kt:26)
    at WorkerKt.main(Worker.kt:62)

这个原因是kotlin-reflect.jar没有添加在classpath里。

在项目的build.gradle添加如下:

Gradle 3.4之前的版:

compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"

Gradle 3.4+

implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
©2020 edoou.com   京ICP备16001874号-3