How to use one module with FCM for 2 apps?

All!

I am building 2 android apps: one for each type of user and want to use as much shared code as possible. So I made 3 modules. One library module with shared code com.example and 2 application modules: com.example.one and com.example.two. Both application modules depend on the library module.

I want to put FCM into the library module. Is that possible? Will it work with only one google-services.json file? How should I configure my project in Firebase console?

Upvotes: 0

Views: 231

Answers (2)

Emre Aktürk
Emre Aktürk

Reputation: 3346

Assume we have two executable module (A and B) and one library module which is C.

We want to A and B depended on C. If C has another dependencies like FCM, A and B also will depend on them over C. This is called transitive dependency.

You need add lines given below to your A's and B's gradle files.

dependencies {
    ...
    compile project(':your_module_name(C in this example)')
}

If want to run separate modules on A & B (assume they dont depend each other, like a tablet and phone application because why not?) You need extra source sets configuration on gradle.

Good luck

Emre

Upvotes: 0

Vij
Vij

Reputation: 445

it is possible , 1)first step to create project in firebase

2) then you can see add app button in that firebase project.

3) then add app for your first app then

4) again add app for to add your second app

5) now generate service.json file ,which file used for your both apps you can copy that file in your both app directory.

Upvotes: 1

Related Questions