https://kotlinlang.org logo
#compose
Title
# compose
j

julioromano

01/26/2022, 8:04 PM
After upgrading to
lifecycle-viewmodel:2.5.0-alpha01
I’m getting compile errors on classes that inherit from `ViewModelProvider.Factory`:
Inheritance from an interface with ‘@JvmDefault’ members is only allowed with -Xjvm-default option
I’ve tried fiddling all
-Xjvm-default=xxxxx
options but the error does not go away. Anyone had the same trouble?
c

Colton Idle

01/26/2022, 11:42 PM
Oooh. I Just got this too after updating. Any luck yet @julioromano?
nope 1
The only additional info I could find is here https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-default/ where there are more option on that flag, but I tried setting them all with no luck. 🤷
think I figured it out. In the module with the problematic code... add
Copy code
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
    kotlinOptions {
        freeCompilerArgs += "-Xjvm-default=enable"
    }
}
j

julioromano

01/27/2022, 12:46 AM
Weird, I tried that too and it kept failing. In the end I reverted to 2.4.0 🤷
c

Colton Idle

01/27/2022, 12:55 AM
I initially put it in my root build.gradle and it didn't work. If you put it in your root you have to surround it with subProjects
Also, be sure to have
-Xjvm-default=enable
NOT
-Xjvm-default
(which I know you said you tried. just highlighting for others in the future)