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

后端 未结 30 1032
走了就别回头了
走了就别回头了 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:30

    If you have many sourcesets/modules it can be cumbersome to configure the jvmTarget for each of them separately.

    You can configure the jvmTarget for all of them at once like so:

    tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
        kotlinOptions {
            jvmTarget = "1.8"
        }
    }
    

    This snippet can be used on top level of your gradle.build file

    After modifying the gradle file Reimport All Gradle Imports. To check if it worked, open Project Structure and verify that IntelliJ correctly assigned JVM 1.8 to all Kotlin-Modules. It should look like this:

    I would not recommend changing the platform directly in IntelliJ, because anyone else cloning your project for the first time is likely to face the same issue. Configuring it correctly in gradle has the advantage that IntelliJ is going to behave correctly for them right from the start.

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

    As it is written in the using-maven docs from the Kotlin website:

    You just have to put <kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget> into the properties section of your pom.xml

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

    please add this code to android section inside your app/build.gradle

    compileOptions {
            sourceCompatibility = JavaVersion.VERSION_1_8
            targetCompatibility = JavaVersion.VERSION_1_8
        }
        kotlinOptions {
            jvmTarget = JavaVersion.VERSION_1_8
        }
    
    0 讨论(0)
  • 2020-11-29 15:32

    The next solution helped me. Add to build.gradle

     compileKotlin {
        kotlinOptions.jvmTarget = "1.8"
    }
    
    compileTestKotlin {
        kotlinOptions.jvmTarget = "1.8"
    }
    
    0 讨论(0)
  • 2020-11-29 15:33

    You can fix this issue as follows:

    • Open the IntelliJ preferences
    • Go to Build, Execution, Deployment > Compiler > Kotlin Compiler BUT Other Settings > Kotlin compiler if Android Studio > 3.4
    • Change the Target JVM version to 1.8
    • Click Apply
    0 讨论(0)
  • 2020-11-29 15:33

    if you are in android project

    in your app's build.gradle under 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"
        }
    }
    
    0 讨论(0)
提交回复
热议问题