Firebase in multi module application

1,532 views
Skip to first unread message

Sarthak Agarwal

unread,
May 28, 2020, 10:06:20 AM5/28/20
to Firebase Google Group
Hi folks ! 

My project has 5 different modules, each containing a set of features which make up the whole application. 
The different modules are - app, domain, data, model and utility with utility being the base module which is inherited by every other module. 
All the modules have different package names - com.example.app, com.example.domain, com.example.utility, etc.

I wanted to know - 
Which package name should I register my app with on the console ?
In which module's build.gradle should I add the google services plugin ?
Where should I put the config file so that it's available to all the modules ? 

Thanks, 
Sarthak

Kato Richardson

unread,
May 29, 2020, 1:59:43 PM5/29/20
to Firebase Google Group, Samuel Stern
Hello Sarthak,

Since they have different package names, I think the correct answer is to add each app into the project, and to download a separate google-services.json for each. +Samuel Stern does that sound correct to you?

☼, Kato

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/2e5b8312-9a0e-474a-ae6e-14e4ce648982%40googlegroups.com.


--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

Sarthak Agarwal

unread,
May 30, 2020, 10:46:11 AM5/30/20
to Firebase Google Group
Isn't that a strange thing ? 
I mean it's just one application contain multiple modules which are interlinked and for it to work I'll have to register it as five different applications on the console ? 
So isn't there any way I can register using the app module and then utilise firebase across all modules ? 


On Friday, May 29, 2020 at 11:29:43 PM UTC+5:30, Kato Richardson wrote:
Hello Sarthak,

Since they have different package names, I think the correct answer is to add each app into the project, and to download a separate google-services.json for each. +Samuel Stern does that sound correct to you?

☼, Kato

On Thu, May 28, 2020 at 7:06 AM Sarthak Agarwal <agarwal.sa...@gmail.com> wrote:
Hi folks ! 

My project has 5 different modules, each containing a set of features which make up the whole application. 
The different modules are - app, domain, data, model and utility with utility being the base module which is inherited by every other module. 
All the modules have different package names - com.example.app, com.example.domain, com.example.utility, etc.

I wanted to know - 
Which package name should I register my app with on the console ?
In which module's build.gradle should I add the google services plugin ?
Where should I put the config file so that it's available to all the modules ? 

Thanks, 
Sarthak

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fireba...@googlegroups.com.

Kato Richardson

unread,
May 31, 2020, 3:08:09 PM5/31/20
to Firebase Google Group
What you're asking for logically makes sense for your app setup. But what you're literally asking for is to register modules with different package names and treat them as if they have the same package name. And the answer to that question is no you cannot. 

If you open up the google-services.json file, you'll see that it references the package name internally. I believe this means that you need a separate file for each separate package and you'll therefore need to register each package in Firebase.

☼, Kato

To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/0ce32f13-4f9e-4181-8f57-d212fcad515e%40googlegroups.com.

Sam Stern

unread,
Jun 1, 2020, 8:25:36 AM6/1/20
to Firebase Google Group
Hi Sarthak,

Firebase only really cares about your app module.  That's the package name you should put into the console, and that's the module where you should apply plugins if possible.  The google-services.json file is only needed to provide values to FirebaseApp.initializeApp().  If it's causing you trouble, you could check out these instructions I wrote on how to do that initialization manually:
https://medium.com/@samstern_58566/how-to-use-firebase-on-android-without-the-google-services-plugin-93ecc7dc6c4

The important thing is to make sure you only call FirebaseApp.initializeApp() once in your app and that it happens before you use any Firebase APIs.  We inject a ContentProvider into your app to make sure of this, but many advanced developers choose to do it themselves.

- Sam

Sarthak Agarwal

unread,
Jun 2, 2020, 10:00:52 AM6/2/20
to Firebase Google Group
Hi Sam and Kato, 

Thanks for the support. It really helped :) 

- Sarthak 


--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fireba...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages