https://kotlinlang.org logo
#android
Title
# android
k

Kulwinder Singh

08/23/2019, 8:15 AM
Why i'm getting
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
while using
viewModel()
function to get fragment's viewmodel ?
l

Luca Nicoletti

08/23/2019, 8:16 AM
check your project jvm target
m

Melvin Biamont

08/23/2019, 8:17 AM
You should have this in your build.gradle
Copy code
android{
(...)

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

}
👍 1
d

Drew Hamilton

08/23/2019, 8:18 AM
Also
kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8
👍 2
k

Kulwinder Singh

08/23/2019, 8:20 AM
OK thanks, but why its required for only this function ?
w

wasyl

08/23/2019, 8:52 AM
@Kulwinder Singh because it’s inline function. You’d get the same error for other inline function from that library (or other libraries built with 1.8 target)
2
k

Kulwinder Singh

08/23/2019, 8:55 AM
thanks @wasyl, it worked with target 1.8
40 Views