Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6

后端 未结 30 1028
走了就别回头了
走了就别回头了 2020-11-29 14:36

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

相关标签:
30条回答
  • 2020-11-29 15:11

    app/build.gradle

    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

    0 讨论(0)
  • 2020-11-29 15:13

    a picture is worth a thousand words

    0 讨论(0)
  • 2020-11-29 15:13

    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.
        }
    }
    
    0 讨论(0)
  • 2020-11-29 15:14

    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.

    • Open File > Project Structure
    • Go to Facets under Project Settings
      • If it is empty then click on the small + button
    • Click on your Kotlin module/modules
    • Change the Target Platform to JVM 1.8 (also it's better to check Use project settings option)
    0 讨论(0)
  • 2020-11-29 15:14

    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

    0 讨论(0)
  • 2020-11-29 15:17

    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.

    0 讨论(0)
提交回复
热议问题