single android project with multiple firebase projects [duplicate] - android

This question already has an answer here:
How to connect to more than one firebase database from an android App
(1 answer)
Closed 12 months ago.
We have an android app for which we have separate firebase projects for each country. Earlier, we had a separate apk for each country and the firebase projects were pre-configured for each project.
The main projects were the same but only the backend and firebase projects were different for the sake of some data compliance issues.
Now, we are working on merging all those projects into a single apk so that the backend and firebase projects will be selected based on the user's login country code.
On playstore, there is a single application that users install. When the user logs in using his phone number, Based on his country dial code, the android app will select the firebase project related to the user's country code.
Currently, the android app is using a single firebase project which is preconfigured in the configuration of the apk. My question is whether it is possible to change the android project on run time or do we always have to preconfigure the firebase project in the android project?

Good question.
We can't create more than one firebase project with same application id.
From my guess you are used different application id for each project before.
And you can manage projects as single project with build variant (many application id's and firebase config using flavors).
Firebase configuration always preconfigured.

Related

Adding multiple firebase projects to one flutter(android portion) project

Up until now I have been working only with one firebase database, which was the test database. Now I wish to add another one, a production database, to my flutter project(the android part). When I try to register the android part of the app to the production database, this is what I get.
If I understand correctly, a package name with the same sha1 fingerprint can't be added to multiple firebase projects, and somewhere I read that the sha1 fingerprint is connected to your computer, so basically you can't change that, and I suppose the package name must be the same as it is in Android Studio.
Any ideas how to add the same project to another(production) firebase database?
You can only add multiple database into one project in Blaze Plan. So a tricky solution, handle the data in two nodes
Production Node
Testing Node
Inside your app code, get the reference accordingly.
You can find the following section in mentioned link
Note: this approach might exceeds your free quota, and after changing your plan to Blaze, you can create multiple databases in one project, but still you will not be able to create new project with the same package name.

Using firebase different apps same project vs different projects

I'm an android developper and i've a few apps published on google play... I do myself every single aspect of my apps including maintence.
I've two similar apps that share some core API... they dont share database nor storage, just some java API of my own and some google cloud functions i made (public)
When i was preparing the firebase infrastructue to run the second one i decided for creating a second app in the same firebase project as the first one... this was a decision made basically because i hated the firebase "switch between projects" tools.
my question is:
what are the advantages and disadvntages of having multiple apps sharing same firebase project?
when should i create a new project for a new app and when should i reuse the project
I'm a single self suficient developper so any sort of "project permissions" wont make difference to me
The primary reason to have multiple apps in the same project is when you want to share database and user data between them. Multiple apps in the same project are definitely expected to share data and configuration across all Firebase products. A common use case is when you have an end-user app and an admin app, both working against the same data.
If you're not sharing data between the apps, then you will only run into future trouble if you have multiple apps in the same project. (For example, see this question which was asked at the same time as yours.)

Limit on number of Firebase projects

I used to add many projects under a Firebase account but this time when I wanted to create a project under Firebase console then it says that You are three projects away. I already had two projects under the console. Is the limit now reduced to 5 apps per account?
I found this info on the firebase faq site
https://firebase.google.com/support/faq/
"How many Firebase apps can I have in a project?
A project is a container for apps across iOS, Android and web. While there is no restriction on number of apps within a project, adding an app can create one or more underlying OAuth 2.0 client IDs. There is a limit of around 30 client IDs that can be created within a single project.
You should ensure that all apps within a project are platform variants of the same application from an end user perspective. For example, if you develop a white label application, each independently labelled app should have its own Firebase project."
In this link, you can find out more about the limitations of Google Project (API Console Project, Google Cloud Project, and Firebase Project). And you will also be able to request quota upgrades when you reach the limit.
Here's an extract:
"If you attempt to exceed your project limit, the console will prompt you to fill out a request form. This happens when you try to create a project but you have already reached your quota. The form will require you to specify the number of additional projects you need, along with their corresponding email accounts, billing accounts, and intended uses."
The limit on the number of projects is not a fixed number. It varies based on your account's standing.
Keep in mind that both Google Cloud projects and Firebase projects count towards the same total number of projects, so be sure to also check console.cloud.google.com for projects.

Seperating dev and prod with android and firebase?

I recently deployed an app to the play store and i am using firebase as backend. However, now I want to add some features to the app and want to create different environments so that i can test the app in a similar environment before releasing to production.
I went through these links online but I have some doubts.
https://medium.com/#Miqubel/multiple-build-types-in-firebase-on-android-6f6715f6dd83
https://web.archive.org/web/20160310115701/https://www.firebase.com/blog/2015-10-29-managing-development-environments.html
The app currently in PROD has database, functions and storage configured. So my goal is to have a mirror image of this setup through which i would test my app without affecting anything in the PROD database setup.
So far what i have figured out is:
1: I need to have different build types in my build gradle.
2: Somehow make my different build for DEV and PROD point to different databases on firebase.
Confusion:
Should I create two different projects on firebase or have two apps in 1 project?
When we have two apps in one firebase project does it have separate database or a single shared database?
It's recommended to have different projects for each environment that you want to test separately. Don't use the same project for development and production, because your changes during development could cause problems in production.
Please read this blog for more information.

Dynamic google services configuration

I have an Android app handling notifications through IBM Bluemix. I created a google-services.json file, added it to the project. It works like a charm.
But now, I want to deploy a generic version of the app to the store. That application will serve different customers, where each customer has to create his own Firebase project and Bluemix account. When initializing, the application should read the necessary ids/secrets from a server instead of getting the values embedded statically in the app.
I saw that the google-services.json file is a convenient way to generate resources in values.xml, but I didn't find how to have these values set dynamically at runtime. Any idea?

Categories

Resources