Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.
This repository was archived by the owner on Dec 9, 2024. It is now read-only.

Process: com.example.schoolsandinstruction, PID: 11787 kotlinx.serialization.SerializationException: Serializer for class 'Companion' is not found. Please ensure that class is marked as '@Serializable' and that the serialization compiler plugin is applied. #264

@Boanerges-Legacy

Description

@Boanerges-Legacy

I have implemented type-safe navigation. My issue is I have a rapper #class with these: val screensInSetup = listOf(
AppScreens.Setup.RegionSetup,
AppScreens.Setup.DistrictSetup,
AppScreens.Setup.SchoolSetup,
AppScreens.Setup.CircuitSetup,
AppScreens.Setup.ManagementUnit,
AppScreens.Setup.AcademicYear
) which has been annotated @serializable. I set up the UI component with it.
GenAdminScreenSh.
This is how the navigation route is set:

LazyVerticalGrid(
columns = GridCells.Fixed(2), modifier = Modifier
.wrapContentSize()
.padding(
smallPadding
)
) {
items(screensInSetup) { screen ->
SetupActionCard(
title = screen.sTitle,
icon = screen.sIcon,
navController = navController,
modifier = Modifier.padding(8.dp),
//onClick = onNavigate
onClick = {
navController.navigate(AppScreens.Setup)
}
)
}
}

This is the card design:
@composable
fun SetupActionCard(
title: String,
@DrawableRes icon: Int,
modifier: Modifier = Modifier,
navController: NavHostController = rememberNavController(),
onClick: () -> Unit = {}
) {
Column(
modifier = modifier
.wrapContentHeight()
.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
Card(
onClick = onClick,
modifier = Modifier
.fillMaxWidth()
.height(68.dp),
elevation = CardDefaults.cardElevation(4.dp),
colors = CardDefaults.cardColors(MaterialTheme.colorScheme.onPrimary)
) {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center,
modifier = Modifier
.fillMaxSize()
.padding(smallPadding) // Ensure full size and centered content
) {
Icon(
painter = painterResource(id = icon),
contentDescription = title,
modifier = Modifier
.size(32.dp)
.padding(end = iconSize), // Set a smaller size for the icon
//tint = MaterialTheme.colorScheme.primary
tint = colorResource(id = R.color.gold)
)
LabelTextComponent1(value = title, color = MaterialTheme.colorScheme.secondary)
}
}
}
}

This is the navGraph

@RequiresApi(Build.VERSION_CODES.O)
@composable
fun AppNavigationGraph(
modifier: Modifier = Modifier,
navController: NavHostController = rememberNavController(),
) {
val dialogOpen = rememberSaveable { mutableStateOf(true) }
NavHost(navController = navController, startDestination = GeneralAdmin) {
composable {
GenAdminScreen(navController = navController)
}

    composable <AppScreens.Setup.SchoolSetup> {
        SchoolSignUpForm()
    }

    composable <AppScreens.Setup.CircuitSetup> {
        CircuitCreatingScreen()
    }

    composable <AppScreens.Setup.ManagementUnit> {
        ManagementUnitScreen()
    }

    composable <AppScreens.Setup.AcademicYear>{
        //AcademicYearScreen()
    }

    composable <AppScreens.Setup.DistrictSetup> {
        DistrictCreatingScreen {}
    }

    composable<AppScreens.Setup.RegionSetup> {
        // RegionProfileCreatScreen()
    }

}

onClick = {
navController.navigate(AppScreens.Setup)
}
How should I handle this error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions