I got this error too but for a different reason. It turns out I had made a typo when I tried to specify the version number as a variable:
dependencies {
// ...
implementation "com.google.android.gms:play-services-location:{$playServices}"
// ...
}
I had defined the variable playServices in gradle.properties in my project's root directory:
playServices=15.0.1
The typo was {$playServices}
which should have said ${playServices}
like this:
dependencies {
// ...
implementation "com.google.android.gms:play-services-location:${playServices}"
// ...
}
That fixed the problem for me.