我刚刚将平台从Windows更改为Mac,当我尝试构建我的应用程序时,我收到以下消息:

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

错误在那一行:
bSettingsLogout.findNavController().navigate(R.id.authenticationActivity)

在Windows上,我使用了较早的3.3 canary版本,但是在开发人员站点上,导航组件没有任何变化。

我不确定是Mac还是Android Studio Canary 6错误。

任何帮助,将不胜感激!

最佳答案

findNavController有2种实现:public static NavController findNavController (View view)public static NavController findNavController (Activity activity, int viewId)但是你用

findNavController()

您缺少所需的参数

10-06 03:24