Connect to Firebase Error in Android

Watch out this error if you are using Firebase with DataBinding or ViewBinding!

Doha Kash
Android in 10 minutes
2 min readNov 27, 2020

--

I’ve been using Firebase in my Android apps for a while and everything was going smooth, until one day suddenly an error kept appearing when I tried to connect a new Android project to Firebase that I have not encountered before. I’m writing this article in case you’ve encountered the same error and was not sure what was going on!

The error in the above image kept showing up every time I try to connect my project to any of Firebase products. I kept checking my build.gradle file and I could not find the source of error, all the dependencies seems updated to the latest versions and nothing is outdated. So what was causing this weird error?

After searching the internet for a while, I found someone who stated in one of Stackoverflow posts that he has just updated his Android Studio to Android studio 4.0 and then after updating he started getting this error.

The Root Cause for the error

The problem for both me and him was that we were still using the obsolete way to add the viewbinding in my case and the dataBinding in his case.

So I was using it this way:

viewBinding {
enabled = true
}

and in his case he was using it with dataBinding :

dataBinding {
enabled = true
}

Changing it to the updated way to use the viewBinding resolved my issue.

So instead you should use the below code :

buildFeatures {
dataBinding = true
// for view binding :
viewBinding = true
}

Hope this will help anyone facing this issue and good luck!

--

--