Type mismatch required TextView Found Int


I am getting an error while trying to assing a textview to another textview variable
I have the import for the textview resource at the top

import com.company.app.R.id.TextViewToAssign

lateinit var textViewToChange:TextView

textViewToChange = TextViewToAssign

It says:

“Type mismatch required TextView Found Int”

I am using

ext.kotlin_version = ‘1.2.31’

Am I using the correct syntax?


You are importing the id, not the view

Try this link:

Or you can use findViewById(ID)


Today, I tried again with:

import kotlinx.android.synthetic.main.layout.*

And it worked, however, and as strange it may sounds, it works randomly: for yesterday textviews, it pointed to a nullpointer, and today is poitning as nullpointer for the textviews created from today.