How to set up Kotlin's byte code version in Gradle project to Java 8?

前端 未结 9 1834
挽巷
挽巷 2020-12-01 08:56

In Kotlin project, what is a proper Gradle script to make sure my classes will be compiled to byte code ver 52 (Java 8)?

For some reason my classes are compiled as v

9条回答
  •  死守一世寂寞
    2020-12-01 09:27

    If you're getting an error like this: Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option.

    Then, you can simply add the following in build.gradle (in Groovy) in order to tell kotlin to build using 1.8.

    compileKotlin {
        kotlinOptions {
            jvmTarget = "1.8"
        }
    }
    

提交回复
热议问题