Android Jetpack Compose java.lang.ExceptionInInitializerError 에러
Search
💄

Android Jetpack Compose java.lang.ExceptionInInitializerError 에러

생성일
2022/04/25 04:04
태그
2022-04-25 13:00:38.262 16465-16465/com.%%% E/AndroidRuntime: FATAL EXCEPTION: main Process: com.%%%, PID: 16465 java.lang.ExceptionInInitializerError at com.hoogi.view.compose.screen.MainScreenKt.BottomBar(MainScreen.kt:82) at com.hoogi.view.compose.screen.MainScreenKt$MainScreen$1.invoke(MainScreen.kt:37) at com.hoogi.view.compose.screen.MainScreenKt$MainScreen$1.invoke(MainScreen.kt:36) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34) at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228) at androidx.compose.material.ScaffoldKt$ScaffoldLayout$1$1$1$bottomBarPlaceables$1.invoke(Scaffold.kt:284) at androidx.compose.material.ScaffoldKt$ScaffoldLayout$1$1$1$bottomBarPlaceables$1.invoke(Scaffold.kt:283) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34) at androidx.compose.ui.layout.SubcomposeLayoutState$subcompose$2$1$1.invoke(SubcomposeLayout.kt:251) at androidx.compose.ui.layout.SubcomposeLayoutState$subcompose$2$1$1.invoke(SubcomposeLayout.kt:251) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34) at androidx.compose.runtime.ComposerKt.invokeComposable(Composer.kt:3337) at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:2582) at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:2571) at androidx.compose.runtime.SnapshotStateKt__DerivedStateKt.observeDerivedStateRecalculations(DerivedState.kt:247) at androidx.compose.runtime.SnapshotStateKt.observeDerivedStateRecalculations(Unknown Source:1) at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:2571) at androidx.compose.runtime.ComposerImpl.composeContent$runtime_release(Composer.kt:2522) at androidx.compose.runtime.CompositionImpl.composeContent(Composition.kt:478) at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:748) at androidx.compose.runtime.ComposerImpl$CompositionContextImpl.composeInitial$runtime_release(Composer.kt:2987) at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:433) at androidx.compose.ui.layout.SubcomposeLayoutState.subcomposeInto(SubcomposeLayout.kt:269) at androidx.compose.ui.layout.SubcomposeLayoutState.access$subcomposeInto(SubcomposeLayout.kt:154) at androidx.compose.ui.layout.SubcomposeLayoutState$subcompose$2.invoke(SubcomposeLayout.kt:244) at androidx.compose.ui.layout.SubcomposeLayoutState$subcompose$2.invoke(SubcomposeLayout.kt:241) at androidx.compose.runtime.snapshots.SnapshotStateObserver.withNoObservations(SnapshotStateObserver.kt:142) at androidx.compose.ui.node.OwnerSnapshotObserver.withNoSnapshotReadObservation$ui_release(OwnerSnapshotObserver.kt:55) at androidx.compose.ui.node.LayoutNode.withNoSnapshotReadObservation$ui_release(LayoutNode.kt:1175) at androidx.compose.ui.layout.SubcomposeLayoutState.subcompose(SubcomposeLayout.kt:241) at androidx.compose.ui.layout.SubcomposeLayoutState.subcompose(SubcomposeLayout.kt:235) at androidx.compose.ui.layout.SubcomposeLayoutState.subcompose$ui_release(SubcomposeLayout.kt:224) at androidx.compose.ui.layout.SubcomposeLayoutState$Scope.subcompose(SubcomposeLayout.kt:490) at androidx.compose.material.ScaffoldKt$ScaffoldLayout$1$1$1.invoke(Scaffold.kt:283) at androidx.compose.material.ScaffoldKt$ScaffoldLayout$1$1$1.invoke(Scaffold.kt:241) at androidx.compose.ui.layout.MeasureScope$layout$1.placeChildren(MeasureScope.kt:68) at androidx.compose.ui.layout.SubcomposeLayoutState$createMeasurePolicy$1$measure$1.placeChildren(SubcomposeLayout.kt:367) at androidx.compose.ui.node.LayoutNode$layoutChildren$1.invoke(LayoutNode.kt:993)
Kotlin
Jetpack Compose를 사용하다 java.lang.ExceptionInInitializerError 이란 에러를 만났다.
원인은 아주 간단 했는데, Compose Nagigation을 쓰기 위해 만든 sealed class에서 string 값을 주려다가 발생했다.

문제

sealed class BottomBarScreen( val route:String, val title: String, ) { object Home:BottomBarScreen( route = "home", title = Resources.getSystem().getString(R.string.home), ) }
Kotlin

해결

sealed class BottomBarScreen( val route:String, val title: Int, ) { object Home:BottomBarScreen( route = "home", title = R.string.profile, ) }
Kotlin
아주 간단한 문제였다.