While developing an app for Android I've been using the newest navigation version from compose, 2.8.3. This allows for much more flexibility around defining routes, but it did throw up an issue that took a while to figure out.
Bottom Navigation Bar
Looking at the sample code on the Navigation With Compose page it all looked simple enough but after adding the code I required I was met with complaints around the line
selected = currentDestination?.hierarchy?.any {
it.hasRoute(topLevelRoute.route::class)
} == true,
The error was
Argument type mismatch: actual type is 'kotlin. reflect. KClass<CapturedType(out CapturedType(out kotlin. Any))>', but 'kotlin. String' was expected.
Given what I could find online this was odd as the newer 2.8.3 code should have been able to use classes??
The answer was that the newer versions define both the original hasString function and a newer companion function. Importing the newer companion function solved the problem and got things working.
import androidx.navigation.NavDestination.Companion.hasRoute
Hopefully this helps someone out, even if just future me 😄