https://kotlinlang.org logo
g

Guilherme Delgado

05/22/2021, 4:41 PM
Hello, I’m having this error:
Copy code
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
Adding support for Java 8 language features could solve this issue.
And if I choose “fix it” the IDE adds this to my
build.gradle.kts
in shared module:
Copy code
android {
   ...
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }
}
Thing is,
kotlinOptions
throws unresolved reference. How can I fix this? Thanks 🙏 ps: don’t know if it’s related or just a coincidence, but I got this error after adding multiplatformSettings lib 🤔
j

John O'Reilly

05/22/2021, 4:45 PM
try this
Copy code
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}
👍 1
g

Guilherme Delgado

05/22/2021, 4:47 PM
perfect @John O'Reilly, thanks!
👍 1
l

louiscad

05/22/2021, 4:49 PM
What AGP version do you have?
g

Guilherme Delgado

05/22/2021, 4:50 PM
Using 4.2.1
l

louiscad

05/22/2021, 4:51 PM
Was it only failing to resolve in the IDE or did Gradle sync or any other Gradle run also failed?
g

Guilherme Delgado

05/22/2021, 4:56 PM
gradle sync was ok, but building was throwing:
Copy code
:shared:compileDebugKotlinAndroid
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
one line per inline operation ^
2 Views