hi! I recently started using the <Accompanist Mate...
# compose-android
k
hi! I recently started using the Accompanist Material Theme Adapter in my app to allow our View and Compose components to use the same shapes, colors, etc, throughout our app. My Previews appear to be broken though with this being the render problem.
Copy code
java.lang.IllegalArgumentException: createMdcTheme requires the host context's theme to extend Theme.MaterialComponents   at com.google.accompanist.themeadapter.material.MdcTheme.createMdcTheme(MdcTheme.kt:173)   at com.google.accompanist.themeadapter.material.MdcTheme.createMdcTheme$default(MdcTheme.kt:162)   at com.designlib.common.ThemeKt.AppTheme(Theme.kt:18)
Anyone know of a way around this? I know AS just uses the IDE to render previews, which wouldn't have a theme to pull from for
createMdcTheme
s
Iirc we had a similar problem and we did something like this:
Copy code
@Preview
@Composable
private fun YourComposablePreview() {
    MdcTheme(context = ContextThemeWrapper(LocalContext.current, R.style.Your_Theme)) {
        YourComposable(
            ...
        )
    }
}
👍 1