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

Lauren Yew

03/30/2022, 4:27 PM
Hi all, has anyone had trouble with
@Composable
interface methods getting
AbstractMethodError
issues? I have a simple interface that I'm using with Hilt to pass Compose Theme components back to a library.
Copy code
import androidx.compose.material.Colors
import androidx.compose.runtime.Composable

interface DevSettingsMaterialTheme {
    @Composable
    fun devSettingsLightColors(): Colors?
...
}

class SampleDevSettingsMaterialTheme : DevSettingsMaterialTheme {
  
    @Composable
    override fun devSettingsLightColors(): Colors? = null // crashes w AbstractMethod
...
}
The library itself was able to implement the interface no problem, and I have tested with one app and it works fine, but another sample app where I'm using the same library (same gradle plugin version 7.1.0 + kotlin version 1.6.10, Java version 11, compose version 1.1.1), when I run the app and try to use the library feature, I get the error
java.lang.AbstractMethodError: abstract method "androidx.compose.material.Colors com...android.devsettings.di.DevSettingsMaterialTheme.devSettingsLightColors(androidx.compose.runtime.Composer, int)"
. Any ideas on how I can work around this? Thanks!
Update: Realizing I might not have set up Compose in the project properly. Working on fixing. Will post back when I have results.
a

Adam Powell

03/31/2022, 1:52 AM
The error definitely looks like the subclass was compiled without the compose plugin enabled. The compose plugin is what adds the
Composer, int
args
46 Views