google / play-services-plugins

Plugins to help with using Google Play services SDK.
https://developers.google.com/android/guides/overview
Apache License 2.0
464 stars 137 forks source link

File google-services.json is missing. Plugin did not search in all flavor locations. #27

Open MartinRajniak opened 5 years ago

MartinRajniak commented 5 years ago

Describe the bug Issue is that plugin can't find google-services.json, but in the list of search locations I don't see some of the source sets for specific flavor in multi flavor project.

So to give an example. Let's say I have this build variant: flavorTest/release.

These are the searched locations:

Actual behaviour "src/release", "src/flavorRelease", "src/flavor", "src/flavor/release", "src/release/flavorTest", "src/flavorTest", "src/flavorTestRelease", "src/flavor/test/release", "src/flavor/testRelease"

Expected behaviour "src/flavorTest/release", "src/release/flavorTest", "src/flavor/release", "src/test/release", "src/flavorTest", "src/release", "src/flavorTestRelease", "src/flavor", "src/flavorRelease", "src/test", "src/testRelease"

Desktop (please complete the following information):

Context Second flavor dimension alone is missing from search locations, so it is impossible to use it to store google-services.json.

davidmotson commented 5 years ago

Because there is no limit on the number of flavor dimensions which can exist, it would get very computationally difficult to traverse all combinations of all flavors in all dimensions. Therefore, for now, we traverse the flavor dimensions linearly in the order they are listed. If you put the flavor dimensions in order: Most general to least general, then you will get the configuration results you are looking for.

MartinRajniak commented 5 years ago

Thank you for explanation.

Then I would argue that it shouldn't be from most general to least general, but rather from least general to most general because this is how the priority is assigned in Android Gradle plugin (from highest to lowest).

In other words, I would say that you want to override the most general by least general (more specific) and in Android Gradle plugin you can only do that by having the least general first followed by the most general.

StuStirling commented 5 years ago

I also noticed this. I have two flavour dimensions, "tester" and "environment" in that order.

What I notice from the trawled directories is that environment directories are not trawled on their own. For example, src/develop. Only src/oneDevelop is searched . This means that if I have a different services JSON for each environment, I have to duplicate it across each variant rather than just placing one in each environment directory

solikhver commented 4 years ago

Thank you for explanation.

Then I would argue that it shouldn't be from most general to least general, but rather from least general to most general because this is how the priority is assigned in Android Gradle plugin (from highest to lowest).

In other words, I would say that you want to override the most general by least general (more specific) and in Android Gradle plugin you can only do that by having the least general first followed by the most general.

I agree with that point. Just checked 4.3.2 version and got next locations order:

Now list sorted ascending by slash count. Seems we have to reverse it.

Blade556 commented 4 weeks ago

Hi, I'm new.