I am using Android Studio 2.0 Preview 4. I\'m using Android SDK tools 25 rc1. This error persists no matter how many times I clean / rebuild project. File->Invalidate Caches
in top level Build.Gradle file use gradle 1.5.0 or above
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
if it is lower than 1.5.0 then use this one also in top level gradle file
classpath "com.android.databinding:dataBinder:1.0-rc4"
This solution worked for me "File -> Invalidate Caches / Restart" https://stackoverflow.com/a/32191257/2205809
You should use:
ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
In onCreate
MainActivity isn't the generated Binding class.
Check the name of the binding class, here ActivityMainInitBinding is generated based on the xml file activity_mail_init.xml. If you use wrong class the error pops up.
val binding : ActivityMainInitBinding=
DataBindingUtil.setContentView(this, R.layout.activity_main_init)