After removing the existing DataBinding
from the project, I also wanted to get rid of the kotlinx.android.synthetic
and replace it with ViewBinding
.
However, after enabling ViewBinding
in my project, I'm still not able to do a proper setup.
Trying to invoke the ViewBinding
into my MainActivity
or in one of my fragments I get the following error in the inflate
method:
Cannot access 'no_name_in_PSI_...' which is a supertype of 'com.example.projectname.databinding.ActivityMainBinding'. Check your module classpath for missing or conflicting dependencies
For example:
MainActivity.kt
class MainActivity : BaseActivity<SharedViewModel>() {
private lateinit var binding: ActivityMainBinding
...
override fun onCreate(savedInstanceState: Bundle?) {
setTheme(R.style.AppTheme)
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
}
}
My build.gradle (:app)
is properly set up:
build.gradle (:app)
android {
...
buildFeatures {
viewBinding true
}
}
I've used ViewBinding
in another project of mine and it worked out of the box. Please help. Thank you so much.