Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:

Wesley Franks
2 min readNov 28, 2020

Let’s dive right into it shall we?

I thought these images might be a bit helpful as I just found a solution to an issue as I started using view binding.

To use view binding you just need to do the following first:

buildFeatures {
viewBinding = true
}

Paste this code inside your app build gradle file.

Then you need to clean your project and rebuild so that you can allow the viewbinding auto generated classes to generate.

You then need to add the following to your fragment or activity (I’m still learning so it could be different in an activity then a fragment).

private var _binding: <YOURFRAGMENTNAME>? = null
private val binding get() = _binding!!

From there you need to inflate the view:

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {

initSignInViewModel()

_binding = SignInBinding.inflate(inflater, container, false)

return binding.root
}

Lastly, you have to use the view like you saw above in the beginning:

The difference is that viewbinding doesn’t like underscores apparently so when typing your view Id be sure to just type “binding.VIEWID…”.

Thanks for reading this article if you felt it helps you please give it a clap and leave a comment letting me know if it helped. I’m going to try to do this more often as I continue to find solutions to problems I face either due to my own ignorance or just plain unknowing. Thanks and have a great one. If you’d like to support me please follow me on the links below.

https://www.twitter.com/wesleyfranks

https://www.instagram.com/wesleyfranks

https://www.facebook.com/wesleyfranks

https://www.youtube.com/wesleyfranks

--

--

Wesley Franks

I write about tech, business, digital marketing and I dabble a bit in android development.