Jetpack Navigation: NavHostManager is not an active fragment of FragmentManager
Solved.
The issue came from the call to the FragmentManager to replace its content with a new instance of the LoginFragment, simply removing the following piece of code from the onCreate method did solve it
if (savedInstanceState == null) {
supportFragmentManager.beginTransaction()
.replace(R.id.container, LoginFragment.newInstance())
.commitNow()
}
Additional explanation since this caused me to scratch my head for a few minutes:
You can create NavHostFragment programmatically using that code from OP's post and answer or you can put app:defaultNavHost="true"
into the fragment in your main activity.
Android Studio will make both of these ways when you create stub files. Either removing OP's code or that property will make it work.