Only solution that I can think of is to add new client to the firebase debug project with package name "com.xyz.myproject.debug" and replace the google-services.json file with this client's json file. I guess, we can't change applicationId but can append using the property applicationIdSuffix which is available to us inside buildVariant closure.
So, my build variant will have :
debug{
//this build uses firebase project which is different from production
signingConfig signingConfigs.debug
applicationIdSuffix ".debug"
}
So this way, I do not have to change applicationId every time when I change the build variant. For Now, I will use this client but the question remains the same. Can't we replace the whole applicationId dynamically instead of appending?