question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No compatibility with MdcTheme

See original GitHub issue

We 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:open
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

3reactions
davidvavracommented, Dec 13, 2021

The root cause is that your activity has a theme Theme.App.NoActionBar which doesn’t inherit from Theme.MaterialComponents

0reactions
davidvavracommented, Oct 17, 2022

@borsini See the workaround I mention in the first post

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found