rickclephas / KMP-ObservableViewModel

Library to use AndroidX/Kotlin ViewModels with SwiftUI
MIT License
569 stars 29 forks source link

Cannot build because invalid JVM target #44

Closed kansson closed 1 year ago

kansson commented 1 year ago

I'm using the latest Android Studio Canary and KMM/KMP plugins. This won't compile and throws the following error.

class TestViewModel : KMMViewModel() {
    @NativeCoroutinesState
    var test = MutableStateFlow(viewModelScope, value = "Hello World!")
}
:shared:compileDebugKotlinAndroid
./TestViewModel.kt:9:16 Cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option

I've tried to search for a solution and tried everything but nothing works.

kansson commented 1 year ago

Got it working, Gradle is so fun sometimes.

lmiskovic commented 1 year ago

Hey, just to provide some more info regarding this issue although I see it is closed, it still might help someone. I've just encountered it and it was resolved by suppressing compiler warning. I've added @file:Suppress("INLINE_FROM_HIGHER_PLATFORM") to affected file and it is compiling again. Credits goes to: https://youtrack.jetbrains.com/issue/KTIJ-20816/Bogus-error-Cannot-inline-bytecode-built-with-JVM-target-11-into-bytecode-that-is-being-built-with-JVM-target-1.8.#focus=Comments-27-7378342.0-0