I have a strange issue when integrate firebase:

In your root build.gradle file add the repo:
allprojects {
repositories {
google()
maven { url "https://maven.google.com" }
}
}
Now Sync Gradle. This is the directory that contains the repos of Firebase.
If the Step 1 doesn't works, then it should be because you are using the Gradle in offline mode. If your gradle is set to offline, android studio searches for the cached copies of the dependencies that you want to update and throws an error since it hasn't downloaded the file before.
Go to Settings >> Build, Execution, Deployment >> Gradle.
In the Global Gradle Settings section, disable Offline mode.
Now Sync Gradle again.