MdcTheme crashes when running a preview
See original GitHub issueRunning a preview on emulator that uses MdcTheme
crashes with the following error:
Caused by: java.lang.IllegalArgumentException: MaterialThemeUsingMdcTheme requires the host context's theme to extend Theme.MaterialComponents
at com.google.android.material.composethemeadapter.MdcTheme.createMdcTheme(MdcTheme.kt:134)
at com.google.android.material.composethemeadapter.MdcTheme.createMdcTheme$default(MdcTheme.kt:125)
at com.google.android.material.composethemeadapter.MdcTheme.MdcTheme(MdcTheme.kt:75)
How to reproduce
Open the MigrationCodelab
project from the android-compose-codelabs end
branch and run any of the previews in the PlantDetailDescription.kt
file.
Versions
- Compose
alpha06
- Android Studio 4.2 Canary 13
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Preview Crashes when using @FetchRequest
I'm trying to load items from the database into a list, it works fine on device and simulator but Preview will always crash...
Read more >Integrating Compose with your existing UI - Android Developers
This tightly couples those View elements together: The custom View may crash or be broken if it can't find the child, and the...
Read more >Converting an existing app screen to Jetpack Compose (Part 1)
Jetpack Compose is now in alpha. In this livestream, we'll go through migrating an existing app screen from using Views and MDC-Android to ......
Read more >Enable theme in jetpack compose preview : r/androiddev
I'm using MdcTheme to integrate existing theme in compose and it working when I built and run on device, but it's not working...
Read more >Jetpack compose preview crashes with hiltViewModel<>()
After some searching and reviewing of google sample codes here is the way you must follow to prevent the preview crashes:.
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 FreeTop 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
Top GitHub Comments
This is more Android Studio issue than issue of this library. I created an issue in Android Studio tracker: https://issuetracker.google.com/issues/209652365
When I try to open the sample project of this repo I get the same error. (I don’t get it in my personal project). When I added a new file with a Preview in it, it previewed correctly once, but after editing/refreshing I keep getting this error again.
Android Studio Arctic Fox | 2020.3.1 Patch 3
This was the preview I tried to add in a new file:
(I was trying to see if the fonts of the theme should work, because that’s not working in preview in my project)