Hello, I'm trying to build a ServerDriven ui app. ...
# navigation-architecture-component
i
Hello, I'm trying to build a ServerDriven ui app. This means I don't have any xml to inflate for my fragments. The problem I'm having is with the
Copy code
androidx.navigation
component. How could I build a graph and destination programatically?
I have some code examples val navController = NavHostFragment.findNavController(homeFragment)
Copy code
// Obtain its id
        val navGraph = NavGraphBuilder(
            id = index,
            provider = navController.navigatorProvider,
            startDestination = homeFragment.id
        ).build()

        val dest = navController.navigatorProvider.getNavigator(FragmentNavigator::class.java)
            .createDestination().apply {
                id = navHostFragment.id   setClassName(HomeFragment::class.qualifiedName!!)     
            }

        navGraph.addDestination(dest)
        navController.setGraph(navGraph)
The problem here is that the HomeFragment gets created twice. And I get a strange error: E/AndroidRuntime: FATAL EXCEPTION: main Process: com.atoss.scsp.android, PID: 9143 java.lang.IllegalStateException: ScrollView can host only one direct child Which is not the case ... I triple checked