当试图通过IntelliJ运行示例CorDapp (GitHub CorDapp)时,我收到以下错误:
不能将使用JVM目标1.8构建的字节码内联为当前的字节码 使用JVM目标1.6构建
如何修改IntelliJ设置,使所有字节码都使用相同的JVM目标构建?
当试图通过IntelliJ运行示例CorDapp (GitHub CorDapp)时,我收到以下错误:
不能将使用JVM目标1.8构建的字节码内联为当前的字节码 使用JVM目标1.6构建
如何修改IntelliJ设置,使所有字节码都使用相同的JVM目标构建?
当前回答
如果在Spring Boot/Kotlin项目中遇到这个消息,只需在pom.xml中将属性“Kotlin .compiler. jvmtarget”设置为“1.8”。
<properties>
<kotlin.version>1.3.70</kotlin.version>
<kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget>
</properties>
...
其他回答
如果你使用Eclipse,假设你下载了Kotlin插件:
右键单击项目->属性-> Kotlin Compiler ->启用项目特定设置-> JVM目标版本“1.8”
我使用Kotlin和Gradle进行正常的JVM开发,(不是android),这在build.gradle中为我工作:
allprojects {
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions.jvmTarget = JavaVersion.VERSION_11.toString()
}
}
如果你在android项目中
在你的应用的build.gradle中 在android {}
android{
//other configs...
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}
在我的例子中,我通过以下两个步骤解决了这个问题
1. Go to android studio preferences -> other settings -> kotlin compiler -> set Target JVM version = 1.8
if it doesn't work then go to the second option.
2. In your module-level build.gradle file add
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
jvmTarget = "1.8"
}
}
在我的例子中,jvmTarget已经在构建中设置了。Gradle文件如下。
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
jvmTarget = "1.8"
}
}
但我的问题依然存在。 最后,在Preferences > Other Settings > Kotlin Compiler >目标JVM版本后,将目标JVM版本从1.6更改为1.8。见附图,