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:
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:
Add Compose Destinations KSP only here.
This is the module where DestinationsNavHost
and the generated NavGraphs
will exist.
Example:
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.