[안드로이드 공부]/Compose
Caused by: java.lang.IllegalArgumentException: MaterialThemeUsingMdcTheme requires the host context's theme to extend Theme.MaterialComponents
코코모모
2023. 7. 21. 16:16
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)
Compose Theme Preview is not showing
Preview 가 보이지 않는다.
@Preview
@Composable
MdcTheme {
...
}
gradle 설정
material = "1.9.0"
com.google.accompanist:accompanist-themeadapter-material
androidx.compose.material:material
MdcTheme 는 AndroidManifest.xml 의 Activity 설정과 연관 되어있다.
즉,
< application
android:theme="@style/Theme.myTheme"
...
applicaiton 에 theme 를 적용 시켜 줘야, Preview가 정상 작동한다.
Preview 문제가 아닐 경우에는
AndroidManifest.xml 의
<activity 에 android: theme를 넣어 주면 된다.