Eka Bayu Pratama
10/05/2025, 2:57 PMUncaught Kotlin exception: kotlin.ArrayIndexOutOfBoundsException
The issue is with the lexendFontFamily variable if I comment it out, the app runs normally.
@Composable
fun rememberLexendTypography(): Typography {
val lexendFontFamily = FontFamily(
Font(resource = Res.font.lexend_light, weight = FontWeight.Light),
Font(resource = Res.font.lexend_regular, weight = FontWeight.Normal),
Font(resource = Res.font.lexend_medium, weight = FontWeight.Medium),
Font(resource = Res.font.lexend_semibold, weight = FontWeight.SemiBold),
Font(resource = Res.font.lexend_bold, weight = FontWeight.Bold),
Font(resource = Res.font.lexend_black, weight = FontWeight.Black),
)
return MaterialTheme.typography.let { typography ->
typography.copy(
displayLarge = typography.displayLarge.copy(fontFamily = lexendFontFamily),
displayMedium = typography.displayMedium.copy(fontFamily = lexendFontFamily),
displaySmall = typography.displaySmall.copy(fontFamily = lexendFontFamily),
headlineLarge = typography.headlineLarge.copy(fontFamily = lexendFontFamily),
headlineMedium = typography.headlineMedium.copy(fontFamily = lexendFontFamily),
headlineSmall = typography.headlineSmall.copy(fontFamily = lexendFontFamily),
titleLarge = typography.titleLarge.copy(fontFamily = lexendFontFamily),
titleMedium = typography.titleMedium.copy(fontFamily = lexendFontFamily),
titleSmall = typography.titleSmall.copy(fontFamily = lexendFontFamily),
bodyLarge = typography.bodyLarge.copy(fontFamily = lexendFontFamily),
bodyMedium = typography.bodyMedium.copy(
fontFamily = lexendFontFamily,
fontWeight = FontWeight.Normal,
fontSize = 16.sp,
),
bodySmall = typography.bodySmall.copy(fontFamily = lexendFontFamily),
labelLarge = typography.labelLarge.copy(fontFamily = lexendFontFamily),
labelMedium = typography.labelMedium.copy(fontFamily = lexendFontFamily),
labelSmall = typography.labelSmall.copy(fontFamily = lexendFontFamily),
)
}
}Ciaran Sloan
10/05/2025, 3:23 PMEka Bayu Pratama
10/05/2025, 3:54 PMEka Bayu Pratama
10/05/2025, 3:55 PM