Cannot change dependencies of configuration \':app:api\' after it has been included in dependency resolution.
For today you can use
classpath 'com.google.gms:google-services:4.0.2'
Seems it works.