androidkotlinandroid-architecture-navigation

Android Navigation Component unresolved reference


I've just changed platform from windows to mac, and when I try to build my app I get this message:

Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public fun `Activity;`.findNavController(viewId: Int): `NavController;` defined in androidx.navigation
public fun `View;`.findNavController(): `NavController;` defined in androidx.navigation

The error is in that line:

bSettingsLogout.findNavController().navigate(R.id.authenticationActivity)

On Windows I've used older 3.3 canary version, but on the developer site nothing changed about navigation components.

I'm not sure if it a mac, or a Android Studio canary 6 error.

Any help would be appreciated!


Solution

  • There are 2 implementations for findNavController:
    public static NavController findNavController (View view) and
    public static NavController findNavController (Activity activity, int viewId)
    but you use

    findNavController()  
    

    you' re missing the needed parameters