question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

google-services.json not found in flavor/build-type directories when using flavors with capital first letter

See original GitHub issue

With 4.2.0 of the plugin the google-services.json was also searched in subdirectories flavor/build-type when the flavor starts with a capital letter. With 4.3.2 it is only searched in the lower-cased version of the flavor.

To Reproduce Steps to reproduce the behavior:

  1. Put google-services.json into a subdirectory <flavor>/<build-type> where <flavor> starts with an uppercase character.
  2. ./gradlew :app:process<flavor><build-type>GoogleServices

Expected behavior Compile succeeds

Screenshots File google-services.json is missing. The Google Services Plugin cannot function without it. Searched Location: /home/kurt/ [REDACTED]/app/google-services.json

Desktop (please complete the following information):

  • Gradle version: 5.6.1
  • Android Studio version: n/a
  • working Plugin name and version: com.google.gms:google-services:4.2.0
  • failing Plugin name and version: com.google.gms:google-services:4.3.2 (as well as 4.3.0)

Additional context Description how to use flavor-specific google-services.json: https://stackoverflow.com/questions/30772201/google-services-json-for-different-productflavors https://android.jlelse.eu/how-to-use-different-google-services-json-file-with-multiple-product-flavors-android-7853d98dd6c0

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:18
  • Comments:13

github_iconTop GitHub Comments

6reactions
volo-droidcommented, Jan 21, 2021

Our app has two flavor dimensions: distribution_channel (with 2 flavors: googlePlay and appCenter) and region (with 3 flavors: europe, asia, americas). The plugin really fails to detect source folders of the flavors and tries to search in a weird locations instead:

▶ ./gradlew :app:assembleEuropeGooglePlayRelease
…
…
> Task :app:processEceGooglePlayReleaseGoogleServices FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processEceGooglePlayReleaseGoogleServices'.
> File google-services.json is missing. The Google Services Plugin cannot function without it.
   Searched Location:
  …/app/src/europeGooglePlay/google-services.json
  …/app/src/release/google-services.json
  …/app/src/europeGooglePlayRelease/google-services.json
  …/app/src/europe/google-services.json
  …/app/src/europeRelease/google-services.json
  …/app/src/europeGooglePlay/release/google-services.json
  …/app/src/release/europeGooglePlay/google-services.json
  …/app/src/europe/release/google-services.json
  …/app/src/europe/google/google-services.json
  …/app/src/europe/googleRelease/google-services.json
  …/app/src/europe/google/release/google-services.json
  …/app/src/europe/google/play/google-services.json
  …/app/src/europe/google/playRelease/google-services.json
  …/app/src/europe/google/play/release/google-services.json
  …/app/google-services.json

As you can see the plugin doesn’t search in app/src/googlePlay or app/src/googlePlayRelease folders, but for some weird reason searches in a location like app/src/europe/google/play/release 🤷‍♂️

6reactions
GFolchezcommented, Apr 28, 2020

Just lost a fair amount of time to this problem. The debug output is almost useless as the getJsonLocations method dies right at the beginning resulting in a default search location and useless error message. Its particularly terrible when your project is working perfectly, and then after some configuration the whole thing fails to compile properly. After trial and error you discover is because you gave your flavor name a capital first letter.

I think what would be the best for this plugin is some sort of configuration block so that you could specify the location of the google services in one of the flavors. Not sure if gradle is capable of this but on a cursory peek at https://docs.gradle.org/current/userguide/custom_plugins.html it would seem it is possible to do direct configuration.

Could a direct configuration obliterate much of the confusion about the location of google-services.json?

Read more comments on GitHub >

github_iconTop Results From Across the Web

google-services.json for different productFlavors
json have to be put at the /app/google-services.json not the flavors folder. Is there any way to make the google-services.json config different for...
Read more >
How to use a Different google-services.json file with ... - Medium
How to use this file for different product flavors. There are only 3 steps first step is so simple just remove the google-service.json...
Read more >
Using Build Types with the Google Services Gradle Plugin
json is missing from module root folder. The Google Services Plugin cannot function without it . This error is thrown by a task...
Read more >
Learning the Basics - Gradle User Manual
This adds repositories which look into one or more directories for finding dependencies. This type of repository does not support any meta-data formats...
Read more >
Custom Tasks - Gradle Recipes for Android [Book] - O'Reilly
Solution. Add task elements to the Gradle build files. Use the extra properties supplied with the Android plug-in to make development easier.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found