How do I change Firebase default project in Terminal - firebase

I'm just starting out using Firebase & firebase cli tools and I'd like to change my default project in terminal. I've switched firebase accounts, but it's still trying to access a default project in my old account.
Anyone got help on this?
Cheers :)

To change the current active project:
firebase use <PROJECT_ID>
Note: If you get errors with deploying your project, make sure that the account you are using is properly authenticated for that project.
firebase logout
firebase login

Related

Log errors from app on Google Play using Crashlytics

Probably silly question, but is it possible to send errors using Crashlytics from users that downloaded my app from Google Play? Until now I was using Crashlytics to collect errors from my app distributed by Firebase (so it was only for me and invited people). But I have released my app on Google Play and I can't see any errors from devices that downloaded my app in Google Play. I read that when I link my Google app with Firebase I can see purchase and subscription and analytics but no mention of Crashlytics. So my question is.. Is it even possible? Thank you very much.
Is the package name the same on your "release" version on the store? If your test one was called com.patrik.coolapp.debug (which is the default if you're using a debug build) then you'll need to add com.patrik.coolapp as an App in your Project in the Firebase console.
If you already had Crashlytics set up (all the dependencies, added the plugin, FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(true) somewhere in your app) then it should just work - here's some advice on testing:
https://firebase.google.com/docs/crashlytics/test-implementation?platform=android
So I finally made it..
I'd like to thanks to #cactustictacs for help.
The problem was that I did not integrate Google Play in project settings in Firebase, although it is saying that it is just for Analytics and Subscription.
Before I integrated Google Play in Firebase I tried to add FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(true) .. it did not work, but I believe it could be usefull to someone.
It wouldn't be such a problem, but it is required to have Owner or Admin permissions on both Firebase account and Google Play console account (which I did not have). After I get the permissions, integration was enabled and I could see test crashes in Crashlytics.

New project not showing on firebase CLI

I have recently had an issue with my firebase account where any new projects don't show in the CLI when I run firebase init. I deleted a project I didn't need, and that updated immediately, any help is greatly appreciated!
There is a simpler solution, first, determine your projectId from the Firebase Console. Firebase usually adds a random number to your project's name i.e if you are using demo as the project name the projectId will look like demo-1234
Next, in your terminal, cd into your project's target directory and issue the followoing command
firebase -P <projectId> init
assuming demo-1234 was my projectId, I will issue the command as below
firebase -P demo-1234 init
Use firebase use --add projectId, this will add your project
Yea this is a weird one.
Use the [don't setup a default project] option
then, as mentioned by #Dragon, use firebase use --add projectId to add the project
I did
firebase logout
then
firebase login
It works for me
The quickest way to do when initializing is by using the --project option:
firebase init --project <projectId>
The below solution worked for me.
Get the Project Id from firebase console. e.g. myproject-2233
On Firebase CLI run below command
$ firebase -P myproject-2233
Next Select the features you want to add e.g. Web Hosting
Next Select "Don't Setup a default project"
Give the public folder name
It worked only after choosing "Don't Setup a default project"
##
Check with firebase login.
You will get redirected to browser and just do sign in.
then firebase -P <Project-ID> init
Then follow all options that come along.
"Which Firebase CLI features do you want to set up for this folder?" Choose "Hosting: Configure and deploy Firebase Hosting sites."
"Select a default Firebase project for this directory:" Choose the project you created on the Firebase website.
"What do you want to use as your public directory?" Enter "build".
Configure as a single-page app (rewrite all urls to /index.html)?" Enter "Yes".
"File build/index.html already exists. Overwrite?" Enter "No".
For me, turns out I was logged into the Firebase CLI using a different account from the one that created the project. The solution was either to log into the CLI with the account that created the project with:
firebase login
or, using the Firebase console, invite the user who's logged into the CLI
Just do a refresh in your firebase console, sometimes the firebase auth token is expired. I had the same issue and after refreshing it fixed for me.

new project not showing up Firebase CLI

Was recently added to a new firebase project via the web interface but it isn't showing up in firebase list. I can see the project in my firebase console. I've tried restarting my terminal, logging out/in, and doing firebase use, but no avail.
Any ideas?
Thanks.
firebase-init first asks which features you wish to use, e.g. database, firestore, storage, etc.
If you choose firestore but have not yet enabled Firestore in your newly created Firebase project via firebase.google.com website, that project will not show up as a project option.
So, before running firebase-cli, enable all the features you want via the website first, ...before chosing those features in step 1 of firebase init.
Once you've enabled Firestore, for example, your project will now show up.
There is now a --project option you can use with firebase init to choose the project.
firebase init --project <projectId>
You can select your project if you know the project id:
firebase use --add
That will select the project, so when you type "firebase init" will not show the select project option but take you to the next step
After 24 hrs, the project finally showed up in my list. Turns out there's just an extremely long delay if you're not the owner of the project.
While following the firebase init steps, use the [don't setup a default project] option.
Then use firebase use --add projectId to add the project.
So recently I changed my password, and was still logged into my firebase account, I did firebase logout and then tried firebase login again, and this time the firebase use --add command worked
In case this helps anyone else: a firebase project is just a firebase-enabled Google Cloud Platform project.
You can create a GCP project but it won't appear in the firebase CLI until you visit console.firebase.google.com and enable firebase for your GCP project of choice.
Then
firebase use --add your_google_cloud_platform_project_id
Should detect your project.
When firebase init asks you to choose a project from the list just check [don't setup a default project] and after the installation you can manually add the project to the .firebaserc file as shown below.
{
"projects": {
"default": "your-project-id"
}
}
You can check the id's of your projects with the command firebase list.
It'll also show the current project.
The below solution worked for me.
Get the Project Id from firebase console. e.g. myproject-2233
On Firebase CLI run below command
$ firebase -P myproject-2233
Next Select the features you want to add e.g. Web Hosting
Next Select "Don't Setup a default project"
Give the public folder name
It worked only after choosing "Don't Setup a default project"

Firebase init error: Unable to authorize access to project [PROJECT ID]

I'm trying to initialize firebase functions for an iPhone app.
I have two separate accounts that I have different firebase projects on.
I ran firebase init, but I get an error
Error: Unable to authorize access to project[PROJECT ID]
where the project ID is a project id for a project in the account im not using.
I used
Firebase use --add
and it worked perfectly.
I ran
Firebase list
and the project I want to init is listed there. But when I ran the init again I got the same error with the wrong project ID still.
ps. the other project ID doesn't come up in Firebase list
EDIT: I logged out of the different account and am logged into the correct account.
You should check the alias. Aren't you just setting your project for staging?
After Firebase use --add, you should do like
What alias do you want to use for this project? (e.g. staging) default
and also
What alias do you want to use for this project? (e.g. staging) dev
In other words, you have to switch all the alias to the project you re trying to use.
This worked for me!
Firebase login to the account that has the project.
If you're switching between two Google accounts, you have to firebase logout from one and firebase login to the other before you can access the projects in those different accounts.

"Error: Permission denied" when running firebase init and choosing database

So I’m testing out the CLI today and firebase init with db/hosting selected, and choosing to create a new project, always says Error: Permission denied..
sudo firebase init didn’t help.
firebase-tools version 3.0.3 on OS X 10.11.5.
firebase init
You're about to initialize a Firebase project in this directory:
/Users/splaktar/Git/tmp
Before we get started, keep in mind:
* You are initializing in an existing Firebase project directory
? What Firebase CLI features do you want to setup for this folder? Database: Deploy Firebase Realtime Database Rules
=== Project Setup
First, let's associate this project directory with a Firebase project.
You can create multiple project aliases by running firebase use --add,
but for now we'll just set up a default project.
? What Firebase project do you want to associate as default? [don't setup a default project]
=== Database Setup
Firebase Realtime Database Rules allow you to define how your data should be
structured and when your data can be read from and written to.
? What file should be used for Database Rules? database.rules.json
Error: Permission denied.
I've tried the answers here but they did not help. Is this just a bug in the firebase-tools?
I have the same issue and this is how I fixed it.
run firebase init
Deselect ❯◯ Database: Deploy Firebase Realtime Database Rules
Go through other steps to setup the initial app, selecting the default for each should work just fine.
run firebase serve
Hope that helps.
Sometimes it could happen when .firebaserc file exists.
Remove .firebaserc file and reattempt firebase init.
I was with the same problem, but I was not accessing the right account.
After accessed the right account, I created a new project and run "firebase list" (before this not happened) and my new project was there.
This solved my problem.
You need to have Owner or Editor IAM permission on the GCP project to use firebase init command.
The firebase init command initializes/enables the project to use Cloud Functions/Hosting etc for Firebase. Owners/Editors have higher permissions that allow APIs to be enabled etc.
it is a first-time task when you starting the development, and then init command can be avoided if you have set up your cloud functions code in VCS for multiple developers or you.
i.e, Usually after writing code, you will replicate the project to other developers, who will then also write code and use firebase use yourprojectid further.

Resources