79746506

Date: 2025-08-26 07:01:16
Score: 1
Natty:
Report link

When using Compose Destinations in a multi-module project, the key is to let each feature module declare its own destinations, and then have the app module aggregate them. If you try to generate navigation code in more than one module, KSP will usually crash.

👉 Steps to fix it:

  1. Feature module (e.g., feature_home, feature_profile):

    Define your screens here with @Destination.

    Don’t add a DestinationsNavHost here. Just expose your Composables.

    Example:


@Destination
@Composable
fun HomeScreen(navigator: DestinationsNavigator) { ... }

2 . Navigation (or app) module:

DestinationsNavHost(
    navGraph = NavGraphs.root
)

3. Dependencies:

 . app (or navigation) module should depend on all feature modules.  

 . Feature modules should not depend on each other, only expose their screens.  

4. Important KSP rule:

 . Only one module (usually app) should apply the ksp plugin for Compose Destinations.  

 . If you enable KSP in multiple modules, you’ll hit the crashes.
Reasons:
  • Long answer (-1):
  • Has code block (-0.5):
  • User mentioned (1): @Destination
  • Starts with a question (0.5): When
  • Low reputation (1):
Posted by: Abdul-Muqaddam