科特林公司;Gradle-确保类路径中有kotlin-reflect.jar
我正在使用Kotlin语言和IntelliJ IDEA中的Gradle构建开发一个应用程序。我遇到以下错误:科特林公司;Gradle-确保类路径中有kotlin-reflect.jar,gradle,intellij-idea,kotlin,Gradle,Intellij Idea,Kotlin,我正在使用Kotlin语言和IntelliJ IDEA中的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 ko
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)
我已经包括了以下答案中提到的依赖项
即使我在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配置一些东西,或者我缺少一些东西?在Build.Gradle(模块:app)中添加实现“org.jetbrains.kotlin:kotlin reflect:$kotlin_version”
从项目级build.gradle
删除compile“org.jetbrains.kotlin:kotlin reflect:$kotlin_version”
是否在IntelliJ中重新导入了修改后的build.gradle
文件?上述答案也适用于定制的gradle构建插件,如果出现一些错误,比如KotlinReflectionNotSupportedError
。对于kotlin-gradledsl,假设您有plugins{kotlin(“jvm”)版本“$kotlin_version”}
,那么您可以说依赖项{compile(kotlin(“reflect”)}