Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Destination for multi module project. #584

Closed
youndon opened this issue Feb 16, 2024 · 2 comments
Closed

Destination for multi module project. #584

youndon opened this issue Feb 16, 2024 · 2 comments
Labels
documentation Improvements or additions to documentation v2.0 Improvement changes under consideration for v2.0

Comments

@youndon
Copy link

youndon commented Feb 16, 2024

I have multi module project working on, And I decided to switch from compose navigation to @destination library.
But I get an issue if I tried to navigate from module to another, Unlike single module that goose well.

For example:

:app

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            DestinationTestTheme {
                // A surface container using the 'background' color from the theme
                Surface(
                    modifier = Modifier.fillMaxSize(),
                    color = MaterialTheme.colorScheme.background
                ) {
                    DestinationsNavHost(navGraph = NavGraphs.root)
                }
            }
        }
    }
}


@RootNavGraph(start = true)
@Destination
@Composable
fun South(
    destinationsNavigator: DestinationsNavigator
) {

    Box {

        Button(onClick = {
            destinationsNavigator.navigate(NorthDestination("azertyu", 132456))

        }) {
            Text("nav to north!")
        }
    }
}

:north

@Destination(start = true)
@Composable
fun North(
    string: String?,
    int: Int?
) {
    Column {
        Text(text = string.toString())
        Text(text = int.toString())
    }
}

The application can run but the exception happen when click the button to navigate the other screen.

The Log:

java.lang.IllegalArgumentException: Navigation destination that matches request NavDeepLinkRequest{ uri=android-app://androidx.navigation/north?string=iuytrhkgfckhygf&int=321654 } cannot be found in the navigation graph ComposeNavGraph(0x78dcd1ef) route=root startDestination={Destination(0xa2cb9a60) route=south}

@raamcosta
Copy link
Owner

Your destinations from one module doesn’t automatically belong to root graph you use to pass to DestinationsNavHost.

Multi module setup is improving greatly for v2 so my advice is stay tuned for documentation I am writing right now and when that is up, use v2.

@raamcosta raamcosta added documentation Improvements or additions to documentation v2.0 Improvement changes under consideration for v2.0 labels Mar 11, 2024
@raamcosta
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation v2.0 Improvement changes under consideration for v2.0
Projects
None yet
Development

No branches or pull requests

2 participants