Giter Club home page Giter Club logo

Comments (97)

samtstern avatar samtstern commented on May 18, 2024 41

Good News Everyone

As of the build com.google.gms:google-services:2.0.0-alpha3 you should be able to put your google-services.json file inside your build flavors directories like this:

app/src/
    flavor1/google-services.json
    flavor2/google-services.json

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.

from google-services.

samtstern avatar samtstern commented on May 18, 2024 26

@shehabix not quite but there is equivalent behavior:

Let's say you have flavor foo and build type release. The plugin looks in the following locations (in this order) and stops when it finds a google-services.json file:

  • app/src/foo/release/google-services.json
  • app/src/foo/google-services.json
  • app/src/release/google-services.json
  • app/google-services.json

from google-services.

adrien-aubel avatar adrien-aubel commented on May 18, 2024 23

@samthor Additionally, this doesn't work with multi-flavor variants.

If I have:

    flavorDimensions 'flavors', 'api'

    productFlavors {
        a {
            dimension 'flavors'
            applicationId 'com.android.a'
        }

        b {
            dimension 'flavors'
            applicationId 'com.android.b'
        }

        standard {
            dimension 'api'
            minSdkVersion 16
        }

        modern {
            // Setting minSdkVersion to 5+ allows us to use Pre Dex and Live Run
            dimension 'api'
            minSdkVersion 21
        }
    }

I have to copy my google-services.json file in both src/aModern/ and src/aStandard/.

The Google Play Services Gradle plugin (2.1.0-alpha5) traverses src/aModern/ but not src/a/, before falling back to src/main/.

The sources and resources processes do traverse both src/a/ after src/aModern/.

from google-services.

bigD666 avatar bigD666 commented on May 18, 2024 13

Stop emailing me
On 25 Nov 2015 08:58, "Andrew Clark" [email protected] wrote:

@ianbarber https://github.com/ianbarber Can you give an example of how
to combine multiple google.services files together when the package name
varies per flavour?


Reply to this email directly or view it on GitHub
#54 (comment)
.

from google-services.

rjam avatar rjam commented on May 18, 2024 13

@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?

from google-services.

jeffreydelooff avatar jeffreydelooff commented on May 18, 2024 9

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?

from google-services.

samtstern avatar samtstern commented on May 18, 2024 7

Ah I see. Can you try putting google-services.json in the app/ folder as well? I think if you have it in all three locations (app/src/release, app/src/debug and app/) the plugin will actually always ignore the root one, but it may just be complaining that one does not exist there.

Either way I will file a bug to get something fixed. If it all works for you, then the bug is simple (don't require a root json file when there are type-specific ones). If it does not all work for you, then we will have to look for a root cause.

from google-services.

samtstern avatar samtstern commented on May 18, 2024 6

@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:

app/
  src/
    FreeDev/google-services.json
    FreeProd/google-services.json
    PaidDev/google-services.json
    PaidDev/google-services.json

from google-services.

condesales avatar condesales commented on May 18, 2024 6

In my case, I just have different app prefixes for each one of the flavours I use.
The google-services.json file has a format like:

{
  "project_info": {
    "project_id": "<project_id>",
    "project_number": "<project_number>",
    "name": "<project_name>"
  },
  "client": [],
  "client_info": [],
  "ARTIFACT_VERSION": "1"
}

As we can see, client is an array. What i've done was add all different clients I have to that array, changing the package_name and any other configuration to match each one of the flavours setup in my build.gradle app file.

from google-services.

 avatar commented on May 18, 2024 6

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? => null/NPE/NullPointerException

No one likes NullPointerException. That's my honest advice.

When I say "honest", I have workaround:

First, add *.json to your .gitignore.

Then:

applicationVariants.all { variant ->
    // Verify your dimension if needed
    if (variant.productFlavors[-1].dimension != 'xxx') return

    // Here's your original json file
    def orgJsonFile = new File(project.projectDir, ...)

    // Here's the temp file
    def tmpJsonFile = new File(project.projectDir, "src/${variant.dirName}/google-services.json")

    // Check to make directory if not existed: tmpJsonFile.parentFile
    // For any parent directory that you make, call #deleteOnExit()

    if (you're on Linux)
        java.nio.file.Files.createSymbolicLink(tmpJsonFile.toPath(), orgJsonFile.toPath())
    else
        tmpJsonFile.text = orgJsonFile.text()

    // Finally:
    tmpJsonFile.deleteOnExit()
}

from google-services.

renejahn avatar renejahn commented on May 18, 2024 5

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?

from google-services.

RobertoAlvarezCeballos avatar RobertoAlvarezCeballos commented on May 18, 2024 5

Hi, my recommendation is to do this:

1.) Forget about having multiple files (I know many people say this works but not in my case)

2.) Create 1 file and put it on /app

3.) Make sure the file has an entry for each of your package names

Run the app, it should work.

Hope it helps.

from google-services.

samtstern avatar samtstern commented on May 18, 2024 5

Ok I have to apologize here, I have misled some people on this thread. I have been using an internal build of the plugin which I assumed was the same as external but apparently there is a commit I have that you don't. So a few things:

  1. Thank you to everyone who has continued to report this. This will definitely be fixed in the next release of the plugin, I will make sure that commit gets in.
  2. The current release supports flavors but not types. So if you create a productflavor (say call it free and another paid) and put the json file in src/$flavorname it will work in the current release. I understand this is extra effort but it's at least something you can do right now.
  3. @MichaelEvans has posted a pretty nifty workaround, good stuff! I haven't tried it but reading the code it looks like it should work if you don't want to use flavors.

Again I apologize for all of the miscommunication so far, I hope this update clears some of the confusion.

from google-services.

samtstern avatar samtstern commented on May 18, 2024 5

@adrien-aubel you're right, currently you do need a JSON file for each combined flavor. I will put that in as a feature request.

from google-services.

samtstern avatar samtstern commented on May 18, 2024 4

Hi all,

I have just confirmed and the changes made it into com.google.gms:google-services:2.1.0-beta1. Please give that a try and let me know if it works for your various use cases. Your reports and patience so far are greatly appreciated.

from google-services.

bskim45 avatar bskim45 commented on May 18, 2024 3

@ghost
App developers are also engineers managing to solve world problems in different dimensions.
Its funny that those projects are treated as 'tiny projects' 🙃

from google-services.

samtstern avatar samtstern commented on May 18, 2024 2

@viralypatel this is a known issue, just make a copy of google-services.json and put it in the app/ folder (that's what the plugin means by the module root folder).

We will release a version soon that fixes this issue.

from google-services.

MichaelEvans avatar MichaelEvans commented on May 18, 2024 2

I wrote up a blog post about a possible workaround here: http://michaelevans.org/blog/2016/03/31/using-build-types-with-the-google-services-gradle-plugin/

from google-services.

shehabic avatar shehabic commented on May 18, 2024 2

In my project I have multiple flavors and multiple build-type so I placed my files as follows:

  • app/google-services.json <-- just to avoid errors from the plugin (File with dummy project_number)
  • app/src/debug/flavor1/google-services.json <-- the file and project for flavor 1 Debug.
  • app/src/debug/flavor2/google-services.json <-- the file and project for flavor 2 Debug
  • app/src/release/flavor1/google-services.json <-- the file and project for flavor 1 Release.
  • app/src/release/flavor2/google-services.json <-- the file and project for flavor 2 Release.

also tried creating the folders as:

  • app/src/flavor1Debug/google-services.json
  • app/src/flavor2Debug/google-services.json
    .
    .
    etc

now when checking the generated files I see that the "clients" are taken properly from the folders, BUT the project_number *(Which is also the GCM Sender Id) is taken from the file on the root (i.e. the "project_number")

Given: I have created 4 projects in Google Play Services Console/Dashboard (1 per flavor's build).

from google-services.

samtstern avatar samtstern commented on May 18, 2024 2

I believe we can finally close this issue as the feature has been implemented. Thanks all!

from google-services.

huck1eberry avatar huck1eberry commented on May 18, 2024 2

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.

from google-services.

ajfclark avatar ajfclark commented on May 18, 2024 1

It'd be nice if there was an "add another service" or something button to make it obvious that you could do that.

from google-services.

MichaelEvans avatar MichaelEvans commented on May 18, 2024 1

@samtstern Any update since Jan 25 on the > File google-services.json is missing from module root folder. issue when using BuildTypes? I have one in app/debug/ and one in app/release but it still can't find it.

from google-services.

originx avatar originx commented on May 18, 2024 1

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

from google-services.

filipmaelbrancke avatar filipmaelbrancke commented on May 18, 2024 1

@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

from google-services.

jpardogo avatar jpardogo commented on May 18, 2024 1

With 2 Flavours dimensions: client & platform.
Log after deleting google-services.json for a client:

Could not find google-services.json while looking in
[

  • mobile/src/client/platform/debug,
  • mobile/src/clientPlatform/debug,
  • mobile/src/debug/clientPlatform,
  • mobile/src/client/debug,
  • mobile/src/client/platform,
  • mobile/src/client/platformDebug,
  • mobile/src/clientPlatform,
  • mobile/src/debug,
  • mobile/src/clientPlatformDebug,
  • mobile/src/client,
  • mobile/src/clientDebug,
  • mobile/
    ]

Those are the paths where the file is searched inside the module.

from google-services.

sky-danilomenezes avatar sky-danilomenezes commented on May 18, 2024 1

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 flavorDimensions (proposition, store and environment), 9 productFlavors (2 propositions, 2 stores and 5 envs) and 3 build types. Which would then generate a variant somewhat like this PROPOSITIONStoreEnvironmentBuildtype
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)

  • We've created a folder app/src/google-services
  • Inside that we've created subfolders for the PROPOSITION then a subfolder for each proposition build type, eg PROPOSITION1/Release
  • We've then created a script attached to the afterEvaluate of the app gradle file which creates a task that will evaluate which combination we're running and then copy the correct google-services.json to /app/src/
  • And then we added the google-services.json of the root to our gitignore
afterEvaluate {
    android.applicationVariants.all { variant ->
        def prepareJsonTask = tasks.create(
                name:"${variant.name}PrepareGoogleServices",
                type: Copy
        ) {
            description = 'Switches to google-services.json depending on flavor'
            from "src/google-services/${getGoogleServicesSrcPath(variant)}"
            include "google-services.json"
            into "."
        }

        variant.preBuildProvider.get().dependsOn(prepareJsonTask)
    }
}

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

from google-services.

ianbarber avatar ianbarber commented on May 18, 2024

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.

from google-services.

silvolu avatar silvolu commented on May 18, 2024

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.

from google-services.

ajfclark avatar ajfclark commented on May 18, 2024

@ianbarber Can you give an example of how to combine multiple google.services files together when the package name varies per flavour?

from google-services.

chrisjenx avatar chrisjenx commented on May 18, 2024

You just keep adding them to the config on the website and it combines them
all together in the JSON file.

On Tue, 24 Nov 2015, 14:28 Andrew Clark [email protected] wrote:

@ianbarber https://github.com/ianbarber Can you give an example of how
to combine multiple google.services files together when the package name
varies per flavour?


Reply to this email directly or view it on GitHub
#54 (comment)
.

from google-services.

ajfclark avatar ajfclark commented on May 18, 2024

@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?]

from google-services.

ajfclark avatar ajfclark commented on May 18, 2024

@bigD666 I'm not. Github is. You must be watching this project or issue or something?

from google-services.

chrisjenx avatar chrisjenx commented on May 18, 2024

@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.

See example:
screen shot 2015-11-24 at 16 07 32

from google-services.

samtstern avatar samtstern commented on May 18, 2024

@ajfclark agreed, we are currently considering the best way to support build flavors in the UI.

from google-services.

yairkukielka avatar yairkukielka commented on May 18, 2024

@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:
screen shot 2015-12-04 at 11 56 11 am

from google-services.

yairkukielka avatar yairkukielka commented on May 18, 2024

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 :)

from google-services.

ajfclark avatar ajfclark commented on May 18, 2024

@yairkukielka That's what we're asking for, not what's currently supported.

from google-services.

yairkukielka avatar yairkukielka commented on May 18, 2024

I see... In that case, +1 to this issue. Flavor support would be very interesting.

from google-services.

stsandro avatar stsandro commented on May 18, 2024

Wow, implementing/including Google Play Services has really become complicated since the last time I've done some Android development!
+1 for this issue! I need this to build multiple apps with different app-ids from the same code base!

from google-services.

chrisjenx avatar chrisjenx commented on May 18, 2024

I think another work around for now would be to create a "core" module which is effectively a library project.
Then create child projects which have their own google-services.json

core
|- freedev
|- freeprod
|- paiddev
|- paidprod

By no means a "good" solution but that would let you do what you need for now.

from google-services.

samtstern avatar samtstern commented on May 18, 2024

There is a workaround for all of this, which involves not using the
google-services plugin at all and just recreating what it would do. The
plugin is meant to be a convenience and it doesn't do anything you can't do
yourself.

The main thing it does is create R.string.google_app_id using the value of
the "mobilesdk_app_id" field from the JSON file.

The other things it does are optional and depend on the APIs you're using.
If you're using GCM it creates R.string.gcm_default_senderId and if you're
using Ads it creates R.xml.global_tracker. If you need these resources,
you can simply create them yourselves.

Most of the other data in the JSON file is not currently used by the plugin
so you can get away with just creating the resources you need in each build
flavor you need them. The plugin does not affect any of your project's
Java code and your app will run fine without it.

On Wed, Dec 9, 2015, 7:08 AM Christopher Jenkins [email protected]
wrote:

I think another work around for now would be to create a "core" module
which is effectively a library project.
Then create child projects which have their own google-services.json

/ core
|- / freedev
|- / freeprod
|- / paiddev
|- / paidprod

By no means a "good" solution but that would let you do what you need for
now.


Reply to this email directly or view it on GitHub
#54 (comment)
.

from google-services.

chrisjenx avatar chrisjenx commented on May 18, 2024

@samtstern OK great, thats good to know, thanks for that!

from google-services.

sregg avatar sregg commented on May 18, 2024

This is still not working for me.
I have app/src/debug/google-services.json and app/src/release/google-services.json and the plugin is still complaining that google-services.json is missing in the root folder.
(using com.google.gms:google-services:2.0.0-alpha3)

from google-services.

m-i-k-e-e avatar m-i-k-e-e commented on May 18, 2024

@sregg probably because you're not using flavors but buildTypes

from google-services.

samtstern avatar samtstern commented on May 18, 2024

Here is the more official google-services document, as promised:
https://developers.google.com/android/guides/google-services-plugin

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)

from google-services.

sregg avatar sregg commented on May 18, 2024

Thanks Sam but that link looks like a private Google link (it asks for username/password)...

from google-services.

sregg avatar sregg commented on May 18, 2024

I'm guessing the correct URL is: https://developers.google.com/android/guides/google-services-plugin

@samtstern so there is no way to use buildTypes (debug/release) instead of flavors?

from google-services.

samtstern avatar samtstern commented on May 18, 2024

Whoops yes: https://developers.google.com/android/guides/google-services-plugin

I accidentally linked to the internal server, sorry about that! I am going to edit the original comment as well, for clarity.

from google-services.

samtstern avatar samtstern commented on May 18, 2024

I think the terminology in this thread has been incorrect the whole time (which is partially my fault, I had been saying build type/build variant/product flavor interchangeably).

I am getting my terminology from here: http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants

If you check out the linked document, you will see that build types are supported (and probably what I meant to be saying all along when I said build flavor).

from google-services.

sregg avatar sregg commented on May 18, 2024

I see, does that mean that you guys changed something recently?
Because 15 days ago it wasn't working: #54 (comment)

from google-services.

sregg avatar sregg commented on May 18, 2024

Awesome!
I'll try again and let you know how it goes.
I'll also try with proper flavors and se if that works fine.

from google-services.

viralypatel avatar viralypatel commented on May 18, 2024

I'm using four different build types as follows:

buildTypes {
    releasefree.initWith(buildTypes.release)
    releasefree {
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    releasepro.initWith(buildTypes.release)
    releasepro {
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        applicationIdSuffix ".pro"
    }
    debugfree.initWith(buildTypes.debug)
    debugfree {
        shrinkResources true
        applicationIdSuffix ".debug"
        debuggable true
    }
    debugpro.initWith(buildTypes.debug)
    debugpro {
        shrinkResources true
        applicationIdSuffix ".pro.debug"
        debuggable true
    }
}

With build variant for ReleaseFree (for one of the product flavors) selected, I Tried adding the google-services.json at

src\release as well as at src\releasefree

Still complains about the json missing from the root module folder. What am i missing?

And can i also put it directly into src\flavor1 or src\flavor2? each build variant has a unique applicationId. tried and wasn't working.

from google-services.

datrixo avatar datrixo commented on May 18, 2024

One step closer. But what in the situation when I have for example GA tracking_id per localization folder.
For example:

  • xml-bg/local_tracker.xml (where is ga_trackingId)
  • xml-pl/local_tracker.xml (where is ga_trackingId)

Unfortunetly google-services.json have "analytics_service" object, where the tracking_id is set per flavor, not per localization.

Any solutions?

from google-services.

samtstern avatar samtstern commented on May 18, 2024

@datrixo I don't think the plugin will be able to support per-region configuration as that information is not (and likely will not be) contained in the JSON file.

In your case I would recommend not using the google-services plugin and just continuing manually as you would have before. If there is any service other than Analytics that you use that will require the google services plugin, you can read this guide to figure out how to recreate the work manually.

from google-services.

bdiegel avatar bdiegel commented on May 18, 2024

I read the guide but I am still confused. My release and debug buildTypes have the same package name. And the generated google-services.json has an oauth_client for each SHA-1. I split them into two files (app/src/debug & release) thinking this was cleaner and also because I plan to support a new product flavor soon. I'm getting the "missing root file" error and saw the recommendation is to put a JSON file in the root folder. Exactly what should that file contain?

[Update] I did some build testing (release and debug) with one app/google-services.json file with both oath_clients. This seems to work, so it is probably the easiest thing to do for now.

from google-services.

samtstern avatar samtstern commented on May 18, 2024

@bdiegel the solution you figured out is correct.

from google-services.

RobertoAlvarezCeballos avatar RobertoAlvarezCeballos commented on May 18, 2024

Hi all, I have the json file on the root and on the debug flavor. When I try to run debug I get the following error "No matching client found for package name XXX.XXXX.XXXX" I have crated the json file for that variant of the package name. I have checked that the name is correct. Does anyone know what may be happening?

from google-services.

fmeneuhe avatar fmeneuhe commented on May 18, 2024

I have the same problem with the debug build. I get rid of the error removing it from the build.gradle:
applicationIdSuffix '.debug'

When is going to be fixed this bug in the Google Services plugin?

from google-services.

RobertoAlvarezCeballos avatar RobertoAlvarezCeballos commented on May 18, 2024

Hi @fmeneuhe yes you can get rid of the error by removing the changes on the package but that's not a solution I guess.

What I've done and it's working so far is to include both package names on the same json file and that' seems to be working. I tried to put different files per build type but it was always using the one on the root not sure why.

from google-services.

fmeneuhe avatar fmeneuhe commented on May 18, 2024

Hi @RobertoIDL , do you mean to modify the json file?

from google-services.

RobertoAlvarezCeballos avatar RobertoAlvarezCeballos commented on May 18, 2024

Hi @fmeneuhe yes I do.

What I've done is copy and paste the block of the JSON that includes package name and add the debug package name as well.

Under the client part of the JSON you will see client info, I have duplicated that one and oauth_client, I have also duplicated that one. And that's it everything else stays the same and it's working is able to find both the debug and the live package name.

Hope it helps.

from google-services.

samtstern avatar samtstern commented on May 18, 2024

@fmeneuhe @RobertoIDL I think there has been some confusion about how the JSON files work. Every time you get a new JSON file (by adding a new Android client, for example) the JSON contains all of the previous information as well. The google-services plugin then scans the file for the appropriate block to match the package name for your build variant.

It's actually a good idea to put identical JSON files in each location, each one containing all of the information for all of your package names, etc. The plugin will be intelligent and only use the correct piece of the file, no need to do manual JSON editing.

from google-services.

RobertoAlvarezCeballos avatar RobertoAlvarezCeballos commented on May 18, 2024

@samtstern I understand that, thanks for clarification.

The problem I had is that if I put the file on each build type location, each file containing only the package name of that build type this didn't work.

from google-services.

fmeneuhe avatar fmeneuhe commented on May 18, 2024

@samtstern this is very confusing.
So, what do we have to do to use the plugin with the debug build and not get the error message "Error:Execution failed for task ... > No matching client found for package name 'mypackagename.debug'"?

from google-services.

samtstern avatar samtstern commented on May 18, 2024

You need to go to developers.google.com/mobile/add and register that package name (mypackagename.debug). Then take the JSON file, and put it in the appropriate folder:

  • app/src - if that is your only package name
  • app/src/debug - if that is your package name only for the debug variant

from google-services.

adauvalter avatar adauvalter commented on May 18, 2024

I'm facing the same problem. I have all google-service.json for each build version from "Get a configuration file" in folders:

/app
/app/src/beta
/app/src/debug
/app/src/integration
/app/src/main

And I'm still receiving an Error:

Execution failed for task ':app:processDebugGoogleServices'.
No matching client found for package name 'XXX.XXX.XXX.dev'

from google-services.

adauvalter avatar adauvalter commented on May 18, 2024

@RobertoIDL do you mean, that I have to create for each package name some client and add it under the section "client" in json file?

from google-services.

RobertoAlvarezCeballos avatar RobertoAlvarezCeballos commented on May 18, 2024

Hi @adauvalter yes that's what I'm saying.

Check your JSON, you will probably have a project info entity, leave that as it is.
Then you have a client section, inside that you need to make sure you have a client_info and oauth_client entities for each of your packages as you will see the package name property is part of this entities.

That's it, once you have that it should work.

from google-services.

kyhule avatar kyhule commented on May 18, 2024

This has been really helpful with all the walls I am running into but one thing I have that may be different than others is my project info is different for each build type. I don't think I can include those in one file.

from google-services.

francescomapelli avatar francescomapelli commented on May 18, 2024

for various reasons we have flavours in different directory than the default app/src/flavor1 app/src/flavor2 etc. ... so we build up the flavours by defining the properties manifest.srcFile, java.srcDirs , res.srcDirs etc.
is there a way to define the google-services.json file in the same way?

from google-services.

samtstern avatar samtstern commented on May 18, 2024

@francescomapelli unfortunately that does not work right now.

Read this guide to find out how to manually configure your app as if you had the plugin. It's generally nothing more than adding a few strings to your strings.xml file.

from google-services.

adamdille avatar adamdille commented on May 18, 2024

@samtstern This presents a big problem for me as well. I use different projects between debug and release build types, so I can't use a single json file because their project_info sections differ. Everything I've read, including the official documentation (https://developers.google.com/android/guides/google-services-plugin#adding_the_json_file) says that build types are supported, but the end result is always the missing from module root folder error. I'm using com.google.gms:google-services:2.1.0-alpha5, but I've also tried several other versions, including com.google.gms:google-services:2.0.0-alpha3, which the documentation specifically mentions being the release that added support for different json files by build type.

from google-services.

AlbertVilaCalvo avatar AlbertVilaCalvo commented on May 18, 2024

@samtstern do you have an estimate of when the next release of the plugin will happen? I can wait for the support of build types. I just want to have an idea of when it will be available.

from google-services.

samtstern avatar samtstern commented on May 18, 2024

The plugin is actually part of the Android Studio source tree which means it's released with (and versioned with) Android Studio releases.

The best way to track this is to watch this page: https://bintray.com/android/android-tools/com.google.gms.google-services/view

The latest is 2.0.0-rc3 which does not have the fix applied. I expect the next release will. This tends to happen on about a weekly pace but in the end it's up to the Studio team.

from google-services.

MichaelEvans avatar MichaelEvans commented on May 18, 2024

@samtstern How about 2.0 that just came out? 😛

from google-services.

samtstern avatar samtstern commented on May 18, 2024

@MichaelEvans unfortunately the 2.0.0 branches are purposely lagging since they're release candidates and they try to test the changes for a while. Look for the change in a 2.1.* release, I will update this thread as soon as I know for sure which one.

In the long term we'd like to get this plugin decoupled from Android Studio since the release schedules should be unrelated.

from google-services.

bskim45 avatar bskim45 commented on May 18, 2024

@samtstern Works perfectly. Thanks.

from google-services.

shehabic avatar shehabic commented on May 18, 2024

@samtstern does this include reading the json from Flavor+Build combination ?
src/flavor1Debug/google-service.json
.
.
src/flavor2Release/google-service.json
etc

from google-services.

shehabic avatar shehabic commented on May 18, 2024

@samtstern thanks a lot for clarifying it

from google-services.

jvanderwee avatar jvanderwee commented on May 18, 2024

Has a feature request been raised for this issue?

from google-services.

samtstern avatar samtstern commented on May 18, 2024

@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.

from google-services.

atanascu avatar atanascu commented on May 18, 2024

@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?

from google-services.

samtstern avatar samtstern commented on May 18, 2024

If you don't need the build types to behave differently with respect to
Google/Firebase then there's no reason to have multiple JSON files.

As for ads service I believe that's just because the back end has been set
up for you already if you decide to use AdMob. If you're not using the
AdMob SDK nothing will happen due to that value.

On Mon, Jul 4, 2016, 8:43 AM schopy [email protected] wrote:

@samtstern https://github.com/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?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#54 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AIEw6g627p66Cp6Z7p6uBzXYl7OD1C5Lks5qSSobgaJpZM4F1F4I
.

from google-services.

bulatgaleev avatar bulatgaleev commented on May 18, 2024

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).

from google-services.

ElineDeMeyer avatar ElineDeMeyer commented on May 18, 2024

Is there already a solution for this issue?

from google-services.

cubbuk avatar cubbuk commented on May 18, 2024

I just need to create 2 flavors for staging and production. I created folders under src respectively and copied google-services.json under folders src/staging and src/production. Each google-services.json under flavor directories contains correct package name for android_client_info i.e. com.myapp.staging or com.myapp.production. However rest of the json files are same i.e. using same api_key etc, only the package name changes according to the flavor name. Do I need to generate new json files from developer console for each flavor, or just changing the package name of each json file is enough? Thanks

from google-services.

Cassio90 avatar Cassio90 commented on May 18, 2024

I'm also looking for a solution to scanning non-combined flavor dimension folders as described here.
Is this feature planned?

from google-services.

toxxmeister avatar toxxmeister commented on May 18, 2024

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.

from google-services.

jpardogo avatar jpardogo commented on May 18, 2024

It is solved now in classpath 'com.google.gms:google-services:3.2.0'

https://bintray.com/android/android-tools/com.google.gms.google-services/3.2.0

from google-services.

flasher297 avatar flasher297 commented on May 18, 2024

Oh my god! With 3.2.0 it finally woks. @jpardogo big thanks for flagging!
I have two flavor dimensions an three build types. Moreover there are six Firebase projects,
And henceforth I can avoid copypasting JSON configurations,

from google-services.

tokou avatar tokou commented on May 18, 2024

Thanks for the update.
There's still an issue for flavor names that contain uppercase characters though 🤔
If I have flavors firstFlavor of dimension dim1 and second of dimension dim2, it only looks in the folders first and firstFlavorSecond but not firstFlavor

from google-services.

Tharkius avatar Tharkius commented on May 18, 2024

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.

from google-services.

jgil-krasamo avatar jgil-krasamo commented on May 18, 2024

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.

from google-services.

ashish-bahl avatar ashish-bahl commented on May 18, 2024

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 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! :)

from google-services.

sky-danilomenezes avatar sky-danilomenezes commented on May 18, 2024

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 flavorDimensions (proposition, store and environment), 9 productFlavors (2 propositions, 2 stores and 5 envs) and 3 build types. Which would then generate a variant somewhat like this PROPOSITIONStoreEnvironmentBuildtype

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?

from google-services.

Tharkius avatar Tharkius commented on May 18, 2024

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 flavorDimensions (proposition, store and environment), 9 productFlavors (2 propositions, 2 stores and 5 envs) and 3 build types. Which would then generate a variant somewhat like this PROPOSITIONStoreEnvironmentBuildtype

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...

from google-services.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.