The other day I was updating a project to support API 26(it’ll have to support 27 too soon enough…) and I decided to also update the Kotlin version in the process. After I updated the project it wouldn’t compile anymore and I was getting a message like this: “Not enough information to infer parameter T”. After taking a closer look at my classes it turned out to be related to my use of findViewById.

Not enough information to infer parameter T

You’re probably wondering why I was even using findViewById…There’s almost no need for it these days because of Kotlin Android Extensions. It’s because I’m inflating a layout and adding it to the WindowManager. This might actually work seamlessly with Kotlin Android Extensions, I’m not too sure. But anyway, fixing this issue is pretty simple. Here’s an example of the way I was previously using findViewById in my project, that caused the issue:

It’s just a matter of moving around whatever View type you’re casting. This is the new version that compiled properly:

Wrap Up

If you’re not already using Kotlin Android Extensions I really recommend taking a look and saying goodbye to findViewById, it’s like ButterKnife for Kotlin but even better. A couple of weeks ago I wrote another post about recurring tasks/jobs and Firebase JobDispatcher – if it sounds like something that could be useful to you feel free to check it out here. Have a great Easter.