Hi everyone, I am using v2.1.0(beta 09) version an...
# compose-destinations
a
Hi everyone, I am using v2.1.0(beta 09) version and vanilla NavHost while implementing compose destination in a multi module project, we need to specify
@Destination<RootGraph>
for a feature level entry screen, my question was why do we have Annotation as compulsory type of
@Destination
, I can see some code snippets in the doc where @Destination is used as follows:
Copy code
@Destination(
    visibility = CodeGenVisibility.INTERNAL // or PUBLIC
)
@Composable
internal fun MyScreen() { /*...*/ }
I cannot use it same way while declaring destination on my side, I have to mention
RootGraph
r
Hi 👋 This was a change made on v2. The docs you’re mentioning, are they part of v2 docs or v1? If they’re from v2, they need fix.
a
Here we are having feature modules and each feature module has a entry point I don’t want to have multiple navGraphs for each feature, I have manually turned off generation of NavGraph:
Copy code
arg("compose-destinations.generateNavGraphs", "false")
only then I am able to use single navGraph, if I remove this setting and build I get following error:
Copy code
[ksp] com.ramcosta.composedestinations.codegen.commons.IllegalDestinationsSetup: NavGraph 'RootGraph' doesn't have any start route. Use corresponding annotation with `start = true` in the Destination or nested NavGraph you want to be the start of this graph!
start = true
I have already declared in app module splash screen, since
@RootGraph
is used in feature module which may not be accessible to the library hence this error is thrown, if you can suggest any solution to this it will be very helpful. TIA
r
It is specifically about this topic
Quick hint is that you probably don’t want to use RootGraph on feature modules. You want to create your own graph and use it in that feature module. Then include it back in the main module as a nested graph. The link above also explains how to do these things 🙂
I actually don’t remember from the top of my head what happens if you use RootGraph in feature modules.. but either it won’t work or it will just be considered its own graph (maybe with the name of the module set on gradle ksp block) and that’s why it’s telling you you need a start destination. All graphs need a start even nested graphs.
Either way, it’s better if you create your own like I said before.
a
Yes I got this now, I was thinking earlier to have it simple by just using
ExternalModuleGraph
but you are right I have to include feature level navGraphs, with their public destination as start true, I will refactor this on my side, thanks for clearing up the confusion 👍
👍 1