Google Services classpath

Hi, I’m the developer of Tower Collector open source app. I want to make it available on F-Droid. Right now it uses Google Analytics. I managed to remove dependency to this proprietary library for app module for dedicated flavor (apply plugin and compile dependency). However there’s still classpath dependency in project build.gradle like this:

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.google.gms:google-services:3.1.1'
    }
}

Unfortunately I can’t find the way to get rid of it just for one flavor (I’d like to keep it in the others). Without this dependency the build fails, I think because it needs to be processed before flavors are defined by Gradle.
Just to let you know I tried to replace Google Analytics with Piwik but it doesn’t meet my expectations in terms of features I need (especially custom metrics).
Do you have experience or know the solution to this particular issue?

I can’t find the way to get rid of it just for one flavor

There’s no such way AFAIK.

Do you have experience or know the solution to this particular issue?

Sure. In this case we call sed -i -e '/com.google.gms/d' from the build recipie and use appropriate flavor.

Seems to be reasonable workaround which didn’t come to my mind, thanks!