The app is not running on Android after using NavController

52 Views Asked by At

On running the code, there are no errors. After clicking on run button it is showing that app is launching on device connected but few seconds later, once it is installed on device connected, I can not open the application and see the fragments developed(which I could earlier). I am using NavController to change the name on the App Bar.

I have checked the navigation graph its destinations all are correct. Have used it as nav_graph in activity.xml. Have set Navigation Controller to nav_graph. Then tried to assign the label of the fragment to the app bar: "NavigationUI.setupActionBarWithNavController(this,navController);"

1

There are 1 best solutions below

0
On

From my experience, errors/inconsistencies in other parts of the application (notably layout/xml) can cause the app to suddenly go off, might not have anything to do with the Nav components. I'd say check for typos, duplications of ids, correct syntax etc.

Can you show code snippets? That'll be a way to help diagnose better. Perhaps also keep the run tab open while running the app (I assume you're using Android Studio) and check the logs to see if any (probably fatal) errors were encountered - that's usually a good pointer to the reason why; but also from my experience, you might need to run the app several times for the system to 'encounter' the very cause before it shows up in the log.

Hope this helps.

PS. You could perhaps backtrack and remove your most recent changes and revert to last stable state, then add the new items one step at a time, checking the code as you run it, just to detect when something leads to the undesirable state.