I'm trying to separate out some Jetpack Compose functions into another library.
On my App Module, I have
setContent {
MyApplicationTheme {
Surface(color = MaterialTheme.colors.background) {
Greeting()
}
}
}
However, composable function MyApplicationTheme comes from another library
@Composable
fun MyApplicationTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
content: @Composable() () -> Unit) { ... }
It compiles fine. But when I run and reach the function triggering MyApplicationTheme, it crashes state
java.lang.NoSuchMethodError: No static method MyApplicationTheme(ZLkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;II)V in class Lcom/example/based_lib/theme/ThemeKt; or its super classes (declaration of 'com.example.based_lib.theme.ThemeKt' appears in /data/data/com.example.myapplication/code_cache/.overlay/base.apk/classes2.dex)
I have a sample design demonstrate the crash... (just need to click the button into the Jetpack Compose activity, it will crash)
https://github.com/elye/issue_android_jetpack_compose_another_library_crash
If I move the MyApplicationTheme from the BasedLib to the Main App, then all compile fine.
Is having a Composable Function in another library not supported, or I need to do something in the library to have the Composable Function usable by another library?
