I want to use Firebase push notifications, but I am running into a configuration conflict. I would like to support different packages. With Google Maps, for example, I can add multiple packages under one app. This is because of Flavors. If My app package is com.example, I may have multiple Flavors such as com.example.a, com.example.b. I want to add support for push notifications for all of these Flavors.
How do I add multiple package names on the Firebase console?
You dont need to create a seperate google-services.json file for each Flavour,
just add the app to the Firebase Project and redownload the generated google-services.json file.
when you add an app the to the firebase Project, it automatically update the google-services.json file with the Client info you have added, so all you need is to download and replace your old one.
Just create seperate google-services.json files for each package you have and put them in their respective src folders
Related
The google-services.json file used by the Firebase Android plugin is usually put in the app's module folder.
What I do want to do instead is put this file somewhere on the filesystem completely outside the project folder and let gradle / the Firebase plugin read it from there.
I thought about putting it's location in the local.properties and somehow 'tell' the Firebase plugin to get the location of the google-services.json from there.
How can I achieve this?
According to offical documentation, the google-services.json file is generally placed in the app/ directory (at the root of the Android Studio app module). As of version 2.2.0 the plugin supports build type and product flavor specific JSON files. All of the following directory structures are valid:
// dogfood and release are build types.
app/
google-services.json
src/dogfood/google-services.json
src/release/google-services.json
...
Note: Providing a google-services.json file in the release directory allows you to maintain a separate Firebase project for your production APKs.
When product flavors are in use these more complicated directory structures are also valid.
// free and paid are product flavors.
app/
google-services.json
src/dogfood/paid/google-services.json
src/release/free/google-services.json
...
As a conclusion, you cannot add google-services.json file outside your project.
Hope it helps.
Can I change the file name google-services.json to prod-google-services.json?
You should not change the name of the file if you intend to use it. If you're going to use different google-services.json file depending on the app environment, you should Configure Product Flavors.
See Firebase 2.0 - how to deal with multiple flavors (environments) of an android app?
You cannot change the google service file name. You can use flavour to manage the google-services.json file.
Like this:
app/src/
flavor1/google-services.json
flavor2/google-services.json
Look here for detail.
Also, very important to note : You should not delete the google-services.json file from your app folder. Firebase will automatically use google-services.json file from flavor folder if it is present and neglect the google-services.json file from app folder. [Thanks #KrishnaAgarwal]
No you can not change file name . it was detected by android gradle while building project.
I am trying to follow the instructions on migrating my app from GCM to the Firebase system, and according to this link, I will have to download the new google-services.json file. However, I have already a previous google-services.json file that was generated when I enabled other APIs (including the GCM).
So my question is how am I supposed to include these two files in my app folder when they have the exact same name? Or am I supposed to paste the json code from the last file to my original one?
Please note that this is not about different flavors, as both google-services.json files refer to the same app configuration.
Thanks!
The google-services.json file is be common across all the firebase components.
If you already downloaded the file from your firebase console then you are good. (every new download should return the same file, provided that you are using the same Firebase project)
If your previous file was generated before the firebase announce then it's worth to migrate your project and re download the file.
For some reason I do not use Android Studio, I compile my apps using a remote server with apache ant so, Is there a way to add firebase analytics, messaging... as libraries?
Firebase is a set of aar (Android Archive) files. Android Studio gradle plugin will simplify the use of the aar files but you can manually configure the app to use the aars. To do so in addition to linking to the libraries you will need to manually merge the manifest from all aar files to your app manifest. That includes permissions, services, receivers, content providers etc. aar is simple zip file. You can open it with unzip (or any other tool that reads zip files) and see the AndroidManifest.xml. You will also need to merge all the resources (if any) for the aar files. The last step will be to add the google_app_id from the generated google-services.json file as string resource. All in all, this is not a trivial work but it is possible.
I have an apk file. I create other android project. I place the apk file within that project. Is it possible to access the Activities in the apk from within the new project (similar to importing classes in a jar)?
You cannot link one APK into another. You can either include the sources and resources from it (perhaps as an Android library project) to access its contents directly, or you can require that the user install it as well and you can invoke its intents.