No compatibility with MdcTheme
See original GitHub issueWe are using MdcTheme
for theme compatibility between our XML-UI and Compose UI. Clicking on section in Showkase UI crashes the app with this exception:
java.lang.IllegalArgumentException: createMdcTheme requires the host context's theme to extend Theme.MaterialComponents
at com.google.android.material.composethemeadapter.MdcTheme.createMdcTheme(MdcTheme.kt:167)
at com.google.android.material.composethemeadapter.MdcTheme.createMdcTheme$default(MdcTheme.kt:156)
at com.google.android.material.composethemeadapter.MdcTheme.MdcTheme(MdcTheme.kt:91)
at com.jll.jet.common.ui.theme.JetPreviewKt.JetPreview(JetPreview.kt:12)
I could workaround the issue with overriding the theme in AndroidManifest.xml like this:
<activity
android:name="com.airbnb.android.showkase.ui.ShowkaseBrowserActivity"
android:label="ShowkaseBrowserActivity"
android:theme="@style/Theme.Jet"
tools:replace="android:theme" />
(Theme.Jet
inherits from Theme.MaterialComponents
)
I’m wondering if the library itself could support this.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
MDC-Android Compose Theme Adapter - GitHub Pages
Compatible with Compose Material; Includes MdcTheme ... If you are using an AppCompat (i.e. non-MDC) theme in your app, you should use AppCompat...
Read more >android - Apply XML theme to Composable with Mdc3Theme
I am trying to migrate an app from XML layouts to jetpack compose. As the app allows setting different user themes, I wanted...
Read more >Integrating Compose with your existing UI - Android Developers
If you have an app with a View-based UI, you may not want to rewrite its entire UI all at once. This page...
Read more >@material/theme - npm
For backward compatibility, $mdc-theme-accent still exists, but it is deprecated. Apps that previously customized $mdc-theme-accent will ...
Read more >Jetpack Compose Theming for Existing Apps (Part 3) Creating ...
When not using Material Design Components ... design system (as it is the case with the MDC theme adapter that is a standalone...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The root cause is that your activity has a theme
Theme.App.NoActionBar
which doesn’t inherit fromTheme.MaterialComponents
@borsini See the workaround I mention in the first post