google / google/play-services-plugins

feature request: Enhance Search Locations for GoogleServicesPluginConfig

Open
#303 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
526
Forks
167
Avg merge
7d 21h
Merged PRs (30d)
2

Description

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:

```kotlin
// 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")
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.