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

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.

Related

How do I set up multiple Firebase projects with the same bundle ID on Android?

I'm working on an Android app that uses Firebase for a few different functions. I'm currently trying to expand from a single Firebase project to 3 to represent development, staging, and production environments.
All of my projects need to use the same bundle ID because of a restriction by another tool I'm using (RevenueCat). What I'm noticing with this setup is that, even when using different google-services.json files, I'm always pointing to my original, production Firebase project.
I've searched around and seen some things about needing to add SHA-1 values on Android to differentiate the apps. I've tried adding the SHA-1 from the app signing key certificate in the Google Play Console to the production project and the SHA-1 from the ./gradlew signingReport output to the staging project. Still no dice, unfortunately.
Does anyone have experience with this kind of setup or any other ideas to try? Thanks so much!
In this case, it turns out I just needed to clear out the app/build folder. Apparently the Firebase configs get "cached" in some way between builds, so clearing it forces it to use the new configuration.
I've just added it as a step in the build process. After this small change, everything is working as expected.
Having several different apps inside one project with the same bundleId/packageName is impossible. You have the possibility to use one google-services.json for several apps, though - you just need to add several apps to your project. The packageName/bundleId of those apps should be different, though.
It is very usual for your case - splitting the app into several flavors to have an appId suffix. For example com.example.app.prod, com.example.app.stage, com.example.app.dev - the suffix can be configure in the gradle.build for each flavor. The issue is that you will have to have different apps inside the firebase project or different projects for each flavor - depending on your needs. For example, when the apps are part of the same project, they will share auth and database storage but will have separate crashlitycs, etc. The different projects will have everything different.
SHA-1 is a bit different thing - it is meant to limit/enable/disable the usage of the APIs based on the signing certificate. There may be several SHA-1 for the same package name. Moreover, SHA-1 only works for Android apps.
What you can do is to create several projects - one for each flavor and register the app under the same package name inside each one - you are able to do that! Each flavor will have to have its own google-services.json file in the appropriate folder.
It works really well with the different package names.
I have never tried this approach with the same packageName, and I don't know the possible drawbacks, so I assume you may face some issues. Or not.
In most of the cases, a simple configuration using google-services.json will be enough for having different Firebase environments in your App. But as we saw, things can get complex very quickly, and depending on the requirements custom ways for configuration and initialization of the Firebase services can be needed. I this article I tried to summarize the different approaches for achieving this goal and share my personal experience. I hope that it was helpful to you and that you enjoyed it.

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.)

Create separate SHA-1 Key for same package ID in Firebase

I've created 2 different firebase projects. One for development and one for production (myProjectDev, and myProject). I've also created an app with Ionic that runs on both ios and android platforms.
I want to use the same bundle/package ID for both firebase projects because if I change the bundle/package ID then I'm forced to setup an entirely separate app in TestFlight/Google play store. I feel like I shouldn't have to do that but then again I'm new to a lot of this.
So with that being said I'm trying to figure out how to generate 2 different SHA-1 keys for the same package ID (com.mycompany.myproject)
I suppose that you can't do that.Instead you can choose paid database instead of Spark so that you can use two separate databases for the same project with same package.

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.

GCM - do i need to save one "google-services"(json file) on two diffrent projects?

i have two projects in android studio. the first one is called "test1" and the second is "test2". i want to use google cloud messaging to communicate with each other. my question is, do i need to use the same "google-services json file (downloaded from google website) on both projects, and also the same project id?
or use diffrent google-services files?
you have to use two different json files, because first project package name and second project package name are different. Google will generate server key depends on package name.
I do not understand the communication word between two different projects. (You mean example to say Facebook send push notifications to Twitter ? )
If you have two different Projects, Yes you need two google-services.json files because both projects have different package names and Sender-ID(i.e Project ID in google console )
If you want communication between two application's (not two different projects), then you can simply use ONE google-services.json file
Note: With out google-services.json file also Servies works well in production but not after releasing your app in public.
Also read What is google-services.json to get clear idea of it.

Categories

Resources