Why i'm getting `Cannot inline bytecode built with...
# android
k
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
check your project jvm target
m
You should have this in your build.gradle
Copy code
android{
(...)

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

}
👍 1
d
Also
kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8
👍 2
k
OK thanks, but why its required for only this function ?
w
@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
thanks @wasyl, it worked with target 1.8