0

I am working on an app that needs two productFlavors, so I modified my gradle file this way:

productFlavors {
    free {
        applicationId = "com.udacity.gradle.builditbigger.free"
    }

    paid {
        applicationId = "com.udacity.gradle.builditbigger.paid"
    }
}

Now since I use Google Ads inside my app, they provided the google-services.json file, now this is causing a lot of trouble. Since this is not something new, I tried this thread.

And I modified my dependencies to:

dependencies {
    classpath 'com.android.tools.build:gradle:2.1.0'
    classpath 'com.google.gms:google-services:2.1.2'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

Now the problem is , when i sync the gradle file, respective directories for free and the paid versions are not created, also, I get an error

Error:Execution failed for task ':app:processPaidReleaseGoogleServices'.

No matching client found for package name 'com.udacity.gradle.builditbigger.paid'

above which Parsing json file:D:\ud867\FinalProject\app\google-services.json failed.

Now, if anyone experienced similar problem, please do share the fix you applied to solve the problem, Thanks!

OBX
  • 6,044
  • 7
  • 33
  • 77

1 Answers1

0

If you already modified your json file this way:

app/src/
flavor1/google-services.json
flavor2/google-services.json
...

as discussed in Adding the JSON File.

Modifying your gradle file in the following format:

android {

    def myFlavors = [
        flavor1: [
            packageName: "com.example.flavor1"
        ],
        flavor2: [
            packageName: "com.example.flavor2"
        ]
    ]

    productFlavors {
        myFlavors.each { name, config ->
            "$name" {
                packageName config.packageName
            }
        }
    }

}

as given in this SO post - Dynamically generating product flavors might help.

Community
  • 1
  • 1
Teyam
  • 7,686
  • 3
  • 15
  • 22