12

I am trying to setup an Android app, using Android Studio with 2 different flavours. Each flavour changes packageName and applicationId - since I want 2 separate APK's submitted as 2 different products to Google Play.

I also try to setup separate apps in Crashlytics, one for each flavour. Although the first one was created without any problem, when I switch flavour, Crashlytics plugin for Android Studio still thinks that my project is already setup. So currently I cannot setup my Crashlytics for second flavour properly.

Thanks in advance for any suggestions.

lookashc
  • 879
  • 8
  • 17

2 Answers2

9

As suggested by m4ch3t3 this workaround worked perfectly:

I created an empty project with package name matching the other flavour. Using this project I created new app in Crashlytics. Then I compiled both flavours of my real project and caused fake crashes in them. Crashes were reported into matching Crashlytics apps

You can define different package name by definining applicationId in your app build.gradle as follow:

productFlavors {

        dev {
            applicationId "dev.myapp.app"
        }

        prod {
            applicationId "prod.myapp.app"
        }
    }
firegloves
  • 5,581
  • 2
  • 29
  • 50
  • Are there no different ApiKeys required per flavour? – Roel Dec 29 '16 at 09:00
  • 1
    No, because fabric differentiates projects with package name. You can use the same api key. This is because your api key is not bound to the project but to the organization – firegloves Dec 29 '16 at 13:46
  • @Roel you can specify different package name as applicationId as showed in my edited answer – firegloves Dec 29 '16 at 13:50
4

Using the Crashlytics plugin for Android Studio will be a PITA in your case.

What you really need is only the API key and secret - shared among the same organisation - so if you already have one app correctly deployed on Crashlytics you can access those data from your organisation profile.

Just log out from the android studio plugin (CTRL+L while the plugin popup is focused), and take a look at this answer that explain how to deal with multiple flavour and multiple keys.

Community
  • 1
  • 1
a.bertucci
  • 12,142
  • 2
  • 31
  • 32
  • 13
    I managed to bypass the issue. I created an empty project with package name matching the other flavour. Using this project I created new app in Crashlytics. Then I compiled both flavours of my real project and caused fake crashes in them. Crashes were reported into matching Crashlytics apps. So everything is working as I wanted. Sadly I needed to use a workaround. – lookashc Sep 07 '14 at 21:30
  • how did you put both key in manifest ? in different resource set ? – Mia Apr 16 '15 at 07:33
  • 1
    @Bastet look at the updated solution proposed at http://stackoverflow.com/questions/25700680/crashlytics-found-an-invalid-api-key/25704532#25704532 – a.bertucci May 02 '15 at 08:49
  • @a.bertucci thank you, I'll try it out, though my goal is using crashlytics / fabric in some of the flavors, I guess it would argue with me if I didn't provide it for all of flavors, and there's still another pain to get the apikey... for what I know for now, we have to run every unique app to get the fabric plugin gain a apikey for us.. it seems like fabric is using ONE apikey for all the flavors.. – Mia May 03 '15 at 09:59
  • @m4ch3t3 I know it's been over a year, but your approach still worked perfectly for me, thanks! :D I hope they fix this.. – TheTool Dec 17 '15 at 10:05
  • @m4ch3t3 solution worked for me. Thanks. Its been over 3 years and still this issue exists. Don't know when Fabric team gonna solve it. – Siju Nov 11 '17 at 11:56