Reputation: 109
I have a perfectly working project. It didn't give any error or anything. But today I upgraded my Android Studio to 4.0 version and Gradle plugin version to 4.0.0. Then I changed my gradle file.
So I change it from this
viewBinding {
enabled = true
}
to this
buildFeatures{
dataBinding = true
}
I sync my project. But it gives "cannot resolve symbol" error with my databindings.
I have a xml named "activity_admin_screen.xml" so I have variable like this
private ActivityAdminScreenBinding binding;
This was working perfectly but now it gives cannot resolve symbol error. I tried invalidate and restart a few times. I deleted project from my computer and clone it from my github again as a new project. I tried to write another xml files. But none of them recognized. I tried to write a new xml named activity_admin_screen2.xml. When I tried to write is as ActivityAdminScreen2Binding Android Studio doesn't recognize it.
I tried to Rebuild my entire project this doesn't help either. Can anyone help me with it I can't run my project.
I didn't post any code because this code works with previous Android Studio version perfectly. After the update no code changed but it doesn't work. I made a research but everyone says there is no need to change bindings. They say Android studio should take care of it. Thanks in advance I am open for any possible solution.
Solution:
I changed this
buildFeatures{
dataBinding = true
}
to this
buildFeatures{
viewBinding = true
}
Now it is working perfectly.
Upvotes: 4
Views: 6245
Reputation: 164
You might want to add both:
android {
buildFeatures {
viewBinding = true
}
buildFeatures {
dataBinding = true
}
}
Upvotes: 2
Reputation: 75798
For android studio 4.0, You should try with viewBinding = true
android {
buildFeatures {
viewBinding = true
}
}
Then Clean-Rebuild
.
Upvotes: 4