Skip to content

feature request: Enhance Search Locations for GoogleServicesPluginConfig #303

Description

@baksha97

When using multiple layers of product flavors, the default search locations for the JSONs are unable to find the service JSON; even if AGP recognizes these directories and automatically adds them to the sources. This disconnect between behaviors forces engineers to go against project resource conventions and create directories to satisfy this plugins expectations.

Here's a minimal example:

// app/build.gradle.kts
flavorDimensions += listOf(
  "market",
  "environment"
)

productFlavors {
  create("amazon") {
      dimension = "market"
  }
  create("google") {
      dimension = "market"
  }
  create("npd") {
      dimension = "environment"
  }
  create("prod") {
      dimension = "environment"
  }
}

We want to store the NPD json in project/app/src/npd (this is a recognized source location for the variant in Android Studio, and probably should be in the default search locations).

Unfortunately, this results in an error:

* What went wrong:
Execution failed for task ':app:processAmazonNpdDebugGoogleServices'.
> File google-services.json is missing. The Google Services Plugin cannot function without it. 
   Searched Location: 
   
project/app/src/amazon/npd/debug/google-services.json
project/app/src/amazonNpd/debug/google-services.json
project/app/src/debug/amazonNpd/google-services.json
project/app/src/amazon/debug/google-services.json
project/app/src/amazon/npd/google-services.json
project/app/src/amazon/npdDebug/google-services.json
project/app/src/amazonNpd/google-services.json
project/app/src/debug/google-services.json
project/app/src/amazonNpdDebug/google-services.json
project/app/src/amazon/google-services.json
project/app/src/amazonDebug/google-services.json
project/app/google-services.json

Suggested Solutions

  1. Modify the default search locations to include a root directory for all flavors, regardless of priority.
  2. Allow clients using the plugin to specify the location of the services JSON in the plugin's GoogleServicesPluginConfig. e.g.
    create("npd") {
        dimension = "environment"
        googleServices {
           servicesJsonFile = File("src/npd/google-services.json")
        }
    }
    

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions