A more up to date answer:
allprojects {
repositories {
google() // add this
}
}
And don't forget to update gradle to 4.1+ (in gradle-wrapper.properties):
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
source: https://developer.android.com/studio/build/dependencies.html#google-maven