I'm following a course and when I write btnDatePicker I get an unresolved error:
package com.example.ageinminutes
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
btnDatePicker
}
}
I've being searching on internet and have added a plugin on build.graddle(:app) as seen on diferent solutions:
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-android-extensions'
}
but it still doesn't work.
Any help will be appreciated.
CodePudding user response:
kotlin-android-extension is deprecated , you should use viewbinding instead.
CodePudding user response:
The answer by @himel
is correct. Using kotlin synthetics is discouraged.
However I did notice that the import line for the synthetic view was not in your code. I suggest typing the view manually and importing with Android studio if you want a quick fix