我正在 IntelliJ IDEA IDE 中使用 Kotlin 语言和 Gradle Build 开发一个应用程序。我收到以下错误:
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)
我已包含以下答案中提到的依赖项在 gradle 中添加 kotlin-reflect 依赖 https://stackoverflow.com/a/36440329/6862286
即使我已经在 libs 文件夹中添加了 jar 文件,但在运行时仍然遇到上述错误。
我的 Gradle 文件如下:
group 'com.working.workerhelp'
version '1.0-SNAPSHOT'
buildscript {
ext.kotlin_version = '1.2.21'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'kotlin'
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
我是否需要为 Gradle Build 配置某些内容,或者我是否缺少某些内容?
add implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
in build.gradle(Module:app)
remove compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
从项目层面build.gradle
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)