Sometimes the following fix will work. Go to your build.gradle of your project and add google() into the repositories element and google() should be the at the top of all the repository.
This is the sample of the repositories block. What you need to do is to add google() or if that exists already, take that to the top of all the line inside repositories
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
maven { url "https://jitpack.io" }
maven { url 'https://maven.google.com' }
}