5

I have different productFlavors specified in my build.gradle file

dev {
        applicationId ""
        versionCode 83
        versionName "2.2.1"
    }
staging {
        applicationId ""
        versionCode 119
        versionName "2.8.1"
    }

both flavors have different project ids etc for google services. i have placed respective google-services.json file in assests folder in each flavor like this

src>dev>assests>google-services.json

and

src>staging>assests>google-services.json

google-services json must be present on root level on compilation.

what should i have to specify in my build.gradle file so that respective file or content should be copied to root folder's file when i build a particular flavor.

enter image description here

SAIR
  • 1,121
  • 11
  • 31
  • you could change package name for each flavor. google-service.json must stay in root folder. – Nguyễn Hoài Nam Mar 24 '16 at 11:19
  • @NguyễnHoàiNam can you elaborate a bit more. – SAIR Mar 24 '16 at 11:26
  • I'm pretty sure that you must setup google-services.json from your developer console. It manage setup by app, with ability to add multiple package names. That's how I use one json for dev/prod flavors. Take a double look at how you get json file and try to add some juice. – Nguyễn Hoài Nam Mar 24 '16 at 11:29
  • yes you are right in that sense and i am using multiple package names and for flavors. The problem is that there are 2 different google console projects are being used. so basically project id and name is different for both. and google-services.json files respectively. – SAIR Mar 24 '16 at 11:35
  • 1
    @Nguyễn Hoài Nam imi not clear on what your saying. the issue seems to be that the developer has multiple application Id and wants to know how to link google-services.json to each one. im also wondering the same thing. forgive me if im wrong, can you enlighten me? but i think the answer can be found here: http://stackoverflow.com/questions/30772201/google-services-json-for-different-productflavors – j2emanue Jan 16 '17 at 05:18
  • 1
    @j2emanue I'm pretty sure my comment is old as the question. The point here maybe: ***The problem is that there are 2 different google console projects are being used*** --> different than the usual case when you setup your app from one Google account. Latest Android Studio and GCM plugin (3.0.0) help you to solve the problem I think. – Nguyễn Hoài Nam Jan 16 '17 at 05:40

0 Answers0