-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BuildType/Flavour Support #54
Comments
If you vary on package name you should be OK - the gradle plugin should pull config from the JSON based on the app's package name. |
It won't solve the GCM senders part though: you got one per app, so the different packages will share the same GCM sender ID. |
@ianbarber Can you give an example of how to combine multiple google.services files together when the package name varies per flavour? |
You just keep adding them to the config on the website and it combines them On Tue, 24 Nov 2015, 14:28 Andrew Clark notifications@github.com wrote:
|
Stop emailing me
|
@chrisjenx Where? I go to https://developers.google.com/mobile/add, pick android, Pick the app and package name, add analytics as a service and then the only option is to generate the config file. [edit: oh, I see now. You have to go in, add a service, generate a config, go back to the original url, add another service, etc. That's horribly non-intuitive. Is there anywhere you can see what's already been added to a project, modify existing services, etc?] |
@bigD666 I'm not. Github is. You must be watching this project or issue or something? |
@ajfclark correct, pick the same "App Name" then add new package names: If you pick the same package name and continue, you can add/see whats added to that config. |
It'd be nice if there was an "add another service" or something button to make it obvious that you could do that. |
@ajfclark agreed, we are currently considering the best way to support build flavors in the UI. |
@samtstern yes, please. This would be great. I have another tricky case with our app: We have 4 build variants: FreeDev, FreeProd, PaidDev and PaidProd. Each of these variants has a Google Services project, so we have 4 Google Services project ids: Free dev, Free prod, Paid dev and Paid prod. Is there a way to get only one google-services.json for all these Google Services projects? If I had only one Google Services account with multiple flavors (package names) I see that I could apply what @chrisjenx is saying, but how do I achieve that for different Google Services projects? If it's not possible, how should I use different google-services.json files in my local project? This is what I see when I try to enable Google Services for my app: |
@yairkukielka there is no way (and there probably never will be) to get one google-services.json file for multiple distinct projects. However with build flavor support you would just have four google-services iles and it would look something like this:
|
ok, Thank you Sam! I thought the plugin only worked when the google-services.json file was placed on the /app root folder. It it works placing the google-services.json file in every flavour's folder, that's not a big deal :) |
@yairkukielka That's what we're asking for, not what's currently supported. |
I see... In that case, +1 to this issue. Flavor support would be very interesting. |
Wow, implementing/including Google Play Services has really become complicated since the last time I've done some Android development! |
I think another work around for now would be to create a "core" module which is effectively a library project.
By no means a "good" solution but that would let you do what you need for now. |
There is a workaround for all of this, which involves not using the The main thing it does is create R.string.google_app_id using the value of The other things it does are optional and depend on the APIs you're using. Most of the other data in the JSON file is not currently used by the plugin On Wed, Dec 9, 2015, 7:08 AM Christopher Jenkins notifications@github.com
|
@samtstern OK great, thats good to know, thanks for that! |
As of the build
I will leave this issue open so that we can collect feedback on whether or not this solves your problems. Thanks for your patience thus far. |
This is still not working for me. |
@sregg probably because you're not using flavors but buildTypes |
So I understand that this could help me with flavors. But in our gradle configuration the dev buildType adds ".dev" to the package name which does not match the package name of google-services.json. Also I have no place for buildType specific google-services.json files. So how do I handle flavors and buildTypes which both append something to the package name? |
Here is the more official google-services document, as promised: I hope that answers many of the questions on this thread. If it does not, feedback appreciated. (Comment edited 1/8/2016 at 9:31am) |
Thanks Sam but that link looks like a private Google link (it asks for username/password)... |
@samtstern I'm still faced with the same issue as @adrien-aubel regarding multi-flavor variants..Any place where we can track the implementation of that feature? |
Has a feature request been raised for this issue? |
@jvanderwee we have seen that request and logged a FR, no hard timeline on when that will be a part of the plugin. Thanks for following up. |
My current set-up includes flavors with custom root directories specified in the sourceSets: {flavor}.setRoot("src/environments/{flavor}") However, the google services plugin doesn't look in those folders. Will this be supported in the future or is there a way to have the project.file resolving of "google-services.json" also look into these custom root directories? |
@samtstern We don't have multiple flavors on our app, but we do have multiple build types. I can see multiple apps in the Firebase console, one per build type. Is there a point in having a google-services.json file per build type considering that the files are identical and they contain multiple client entries, one for each build type? And do you know why ads_service has a status 1 by default? |
If you don't need the build types to behave differently with respect to As for ads service I believe that's just because the back end has been set On Mon, Jul 4, 2016, 8:43 AM schopy notifications@github.com wrote:
|
Move the default google-services.json (so fresh clones and travis can build because the gradle plugin requires the file to be present) to the lowest priority location, and ensure that the flavor-specific locations are ignored. This way, prod builds can have its file in android/src/prod/ and a debug build pointing to a dev instance can have one in android/src/debug/ See this comment: googlesamples/google-services#54 (comment) for the order of file location searches
What if i want to use different google-services.json within 1 flavor? (my app should be able to dynamically switch environments - each environment is a seperate Google Project). |
Is there any way to raise prio on #54 (comment) Like this it would be much easier to have a clean setup per dimension, especially if they are separate firebase projects. Another alternative would be combining all projects and apps into 1 google-json file but I believe supporting fallback to dimensions before going to main would solve all flavor type issues. or ability to define google-json file location per product flavor config which would override default file traversal algorithm |
@localhostEU : I arrived at this issue looking for a solution to the same problem, and I'd like to point out that there is some information now: https://firebase.googleblog.com/2016/12/working-with-multiple-firebase-projects-in-an-android-app.html |
Is there already a solution for this issue? |
I just need to create 2 flavors for |
I'm also looking for a solution to scanning non-combined flavor dimension folders as described here. |
For the issue from comment #204587543:Google is solving the world problems. They're sending their engineers around NASA, Tesla, Whit House to tackle world problems. Last time I heard, they were building smart condoms. Next API for you Android devs would be Condom Wearable. Again, what do your tiny projects mean to Google? =>
|
@ghost |
My current workaround is attaching to the plugin's task and copying the required flavor's JSON to the module's root: val gmsPattern = Regex("""process([A-Z][a-z]*).*GoogleServices""")
tasks.withType<GoogleServicesTask> {
gmsPattern.matchEntire(name)?.destructured?.let { (flavor) ->
doFirst {
copy {
from("src/${flavor.toLowerCase()}/google-services.json")
into(".")
}
}
}
} It's written in Gradle Script Kotlin, but it shouldn't be much different in Groovy. |
It is solved now in https://bintray.com/android/android-tools/com.google.gms.google-services/3.2.0 |
Oh my god! With 3.2.0 it finally woks. @jpardogo big thanks for flagging! |
Thanks for the update. |
With 2 Flavours dimensions: client & platform.
Those are the paths where the file is searched inside the module. |
Have the same issue with flavor names containing uppercase characters. Flavor root folder (module/src/<flavour_with_some_uppercase_letters>) is "ignored" by the plugin. The search is performed only within module's root and module/src/<flavour_with_some_uppercase_letter>/debug (or release) folder. |
I'm also facing this issue, took a while to understand it was a bug. I see the compiler prints a message saying something like "MyFlavour/debug/ failed to parse into flavors. Please start all flavors with a lowercase character". This is completely unacceptable, IMO. There are many projects out there (including the one I'm working on), which already have the flavour dimensions set-up with uppercase letters, and it makes no sense to me that we should be changing our configurations, just because the plugin won't work with uppercase letters. Is there a separate issue for this bug? EDIT: For those struggling with the same issue, I have found a workaround at this link. |
Okay, the current problem is that if you're using two dimensions, the file is searched in the folder of the first declared dimension, but never in the folder of the second one. |
I stumbled upon this comment and decided to give this a try. Changed all the upper class flavor folder names to lower case and gave it a whirl. It all works like a charm now, thanks a ton! :) |
So in our case we have many more flavours and build types combinations than what gradle would generate the correct folders for us, so we have some custom sourceSets. We have 3 The problem for us is that the plugin is stopping the search on the first matching case where it finds a json. We have a json for PROPOSITION and PROPOSITIONRelease folders, and it will stop the search when it finds the one inside PROPOSITION... I don't see any way of working around this, any ideas? |
In your case I would say to get rid of the PROPOSITION folders, create a PROPOSITIONRelease folder for every possible configuration and add the json file in each of those folders, duplicating if need be. You will probably end up with a lot of folders and duplicate jsons, but hey, it's a solution :D I actually had to do that for the project I was working on at the time... |
So we got it working with a different approach but with the same motto (it works)
Edit: We actually got it working by creating the build types folder under the proposition... PROPOSITION/debug, PROPOSITION/release etc. Plugin worked just fine after that |
I have had a look, I can't see another issue.
How do we enabled different configs per flavour/buildType? Most Common use case is where we have different analytics tracking and GCM senders per debug/release builds.
Favours would be an added bonus.
Thanks.
The text was updated successfully, but these errors were encountered: