When trying to run the Example CorDapp (GitHub CorDapp) via IntelliJ, I receive the following error:
Cannot inline bytecode built with JVM target 1.8 int
android {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
}
GL
Use Java 8 language features
a picture is worth a thousand words
You may need to set both compileKotlin
and compileTestKotlin
.
This works on gradle 6.5.1.
compileKotlin {
kotlinOptions {
languageVersion = "1.2"
apiVersion = "1.2"
jvmTarget = "1.8"
javaParameters = true // Useful for reflection.
}
}
compileTestKotlin {
kotlinOptions {
languageVersion = "1.2"
apiVersion = "1.2"
jvmTarget = "1.8"
javaParameters = true // Useful for reflection.
}
}
When the other solutions did not work for you (Changing JVM version on Compiler settings and adding jvmTarget
into your build.gradle
), because of your .iml
files trying to force their configurations you can change the target platform from Project Settings.
File > Project Structure
Facets
under Project Settings
+
buttonTarget Platform
to JVM 1.8
(also it's better to check Use project settings
option)All answers here are using gradle but if someone like me ends up here and needs answer for maven:
<build>
<sourceDirectory>src/main/kotlin</sourceDirectory>
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<jvmTarget>11</jvmTarget>
</configuration>
</plugin>
</plugins>
</build>
The change from jetbrains archetype for kotlin-jvm is the <configuration></configuration>
specifying the jvmTarget. In my case 11
Nothing worked for me until I updated my kotlin plugin dependency.
Try this:
1. Invalidate cahce and restart.
2. Sync project (at least try to)
3. Go File -> Project Structure -> Suggestions
4. If there is an update regarding Kotlin, update it.
Hope it will help someone.