zenith
zenith

Reputation: 55

Use 2 different firebase projects for FCM and Crashlytics with android

I am trying to use 2 different Firebase projects with android, one for FCM and another for Crashlytics(say ProjectA for FCM and ProjectB for Crashlytics). But it's not working for me.

I am initialising Firebase manually. As soon as my app starts I initialise Firebase for FCM using ProjectA configuration.

val options = FirebaseOptions.Builder()
            .setProjectId(fcmOptions[5]!!)
            .setApplicationId(fcmOptions[0]!!) 
            .setApiKey(fcmOptions[1]!!) 
            .setDatabaseUrl(fcmOptions[2]) 
            .setGcmSenderId(fcmOptions[3])
            .setStorageBucket(fcmOptions[4])
            .build()

FirebaseApp.initializeApp(this, options)

Till here it is fine, the token gets generated and I am able to receive Push notifications.

After this on click of a button I register for Crashlytics using ProjectB configuration.

val options = FirebaseOptions.Builder()
            .setProjectId(crashlyticsOptions[5]!!)
            .setApplicationId(crashlyticsOptions[0]!!) 
            .setApiKey(crashlyticsOptions[1]!!) 
            .setDatabaseUrl(crashlyticsOptions[2]) 
            .setStorageBucket(crashlyticsOptions[4])
            .build()

FirebaseApp.initializeApp(this, options, "crashlytics")

After this step I cause a few crashes so that I can see the crashes in Crashlytics dashboard. The problem here is that the crashes don't appear under ProjectB Crashlytics console which is what I expect. But the crashes appear under the ProjectA for FCM.

Has anyone tried such scenario before and can help me out.

Upvotes: 1

Views: 424

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317467

Crashlytics does not support using a secondary project to capture crashes. It will only use the default project (the one you initialized without a name). FCM and Analtyics are the same way.

Upvotes: 2

Related Questions