How to host flutter on firebase? - firebase

I am following the steps to host my flutter helloworld application. All steps go smooth, however instead of my application I see this screen.
What can be wrong?
My commands:
polinach-macbookpro3:my_app1 polinach$ flutter build web
💪 Building with sound null safety 💪
Compiling lib/main.dart for the Web... 391ms
polinach-macbookpro3:my_app1 polinach$ firebase init hosting
######## #### ######## ######## ######## ### ###### ########
## ## ## ## ## ## ## ## ## ## ##
###### ## ######## ###### ######## ######### ###### ######
## ## ## ## ## ## ## ## ## ## ##
## #### ## ## ######## ######## ## ## ###### ########
You're about to initialize a Firebase project in this directory:
/Users/polinach/_/__/my_app1
=== 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.
? Please select an option: Create a new project
i If you want to create a project in a Google Cloud organization or folder, please use "firebase projects:create" instead, and return to this command when you've created the project.
? Please specify a unique project id (warning: cannot be modified afterward) [6-30 characters]:
polina-test2
? What would you like to call your project? (defaults to your project ID)
✔ Creating Google Cloud Platform project
✔ Adding Firebase resources to Google Cloud Platform project
🎉🎉🎉 Your Firebase project is ready! 🎉🎉🎉
Project information:
- Project ID: polina-test2
- Project Name: polina-test2
Firebase console is available at
https://console.firebase.google.com/project/polina-test2/overview
i Using project polina-test2 (polina-test2)
=== Hosting Setup
Your public directory is the folder (relative to your project directory) that
will contain Hosting assets to be uploaded with firebase deploy. If you
have a build process for your assets, use your build's output directory.
? What do you want to use as your public directory? build/web
? Configure as a single-page app (rewrite all urls to /index.html)? Yes
? Set up automatic builds and deploys with GitHub? No
? File build/web/index.html already exists. Overwrite? Yes
✔ Wrote build/web/index.html
i Writing configuration info to firebase.json...
i Writing project information to .firebaserc...
✔ Firebase initialization complete!
polinach-macbookpro3:my_app1 polinach$ firebase deploy --only hosting
=== Deploying to 'polina-test2'...
i deploying hosting
i hosting[polina-test2]: beginning deploy...
i hosting[polina-test2]: found 21 files in build/web
✔ hosting[polina-test2]: file upload complete
i hosting[polina-test2]: finalizing version...
✔ hosting[polina-test2]: version finalized
i hosting[polina-test2]: releasing new version...
✔ hosting[polina-test2]: release complete
✔ Deploy complete!
Project Console: https://console.firebase.google.com/project/polina-test2/overview
Hosting URL: https://polina-test2.web.app

Look at this part of your output:
? What do you want to use as your public directory? build/web
? Configure as a single-page app (rewrite all urls to /index.html)? Yes
? Set up automatic builds and deploys with GitHub? No
? File build/web/index.html already exists. Overwrite? Yes
✔ Wrote build/web/index.html
You told it to overwrite the existing build/web/index.html. That's what you're seeing in the browser - the HTML provided by the Firebase CLI.
You will need to make sure your "public directory" (which you set as "build/web") contains what you want to deploy with an index.html to serve by default before you run firebase deploy.

Related

firebase cli tells me I have no emulators configured when I just successfully configured some

I am trying to use the firebase emulator.
I have run firebase init emulators (selected an existing project) and the selected the emulators I want to init (firestore and auth).
It then says the the emulator initialization succeeded.
I then proceed to run firebase emulators:start and it says "no emulators initialized", even though the cli command JUST said that emulators were initialized.
Observe the complete output...
user#devmachine:~/src/firebase-emulator-project$ firebase init emulators
######## #### ######## ######## ######## ### ###### ########
## ## ## ## ## ## ## ## ## ## ##
###### ## ######## ###### ######## ######### ###### ######
## ## ## ## ## ## ## ## ## ## ##
## #### ## ## ######## ######## ## ## ###### ########
You're about to initialize a Firebase project in this directory:
/home/user/src/firebase-emulator-project
Before we get started, keep in mind:
* You are initializing within an existing Firebase project directory
=== 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.
i .firebaserc already has a default project, using my-existing-project.
=== Emulators Setup
? Which Firebase emulators do you want to set up? Press Space to select emulators, then Enter to confirm your choices. (Press <space> to select, <a> to toggle all, <i> to invert selection)
i Writing configuration info to firebase.json...
i Writing project information to .firebaserc...
✔ Firebase initialization complete!
user#devmachine:~/src/firebase-emulator-project$ firebase emulators:start
i emulators: Shutting down emulators.
Error: No emulators to start, run firebase init emulators to get started.
user#devmachine:~/src/firebase-emulator-project$
EDIT: Just to recap for people who might struggle with reading...
run firebase init emulators
select my existing project from the list of projects.
Select 'firestore' and 'auth' emulators to init.
firebase cli outputs "Firebase Initialization Complete!", and indicates no errors.
run firebase emulators:start , firebase cli outputs error Error: No emulators to start, run firebase init emulators to get started..
I expected the emulators to start.

firebase init Error: HTTP Error: 403, Permission denied to get service [firebasedatabase.googleapis.com]

I'm trying to use firebase init with package firebase, firebase-admin and firebase-tools. I've downloaded the json file from the firebase console and I've put it on the server, then i run firebase init function. there i choose realtime database and use existing project
but after that function run i get error
Error: HTTP Error: 403, Permission denied to get service [firebasedatabase.googleapis.com]
Help Token: ***this is help token***
here are the details of the results of the firebase init that I did
root#api:/var/www/api/public_html# firebase init
######## #### ######## ######## ######## ### ###### ########
## ## ## ## ## ## ## ## ## ## ##
###### ## ######## ###### ######## ######### ###### ######
## ## ## ## ## ## ## ## ## ## ##
## #### ## ## ######## ######## ## ## ###### ########
You're about to initialize a Firebase project in this directory:
/var/www/api/public_html
Before we get started, keep in mind:
* You are currently outside your home directory
? Which Firebase features do you want to set up for this directory? Press Space to select features, then Enter to confirm your choices. Realtime Databas
e: Configure a security rules file for Realtime Database and (optionally) provision default instance
=== 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.
? Please select an option: Use an existing project
? Select a default Firebase project for this directory: api (Api)
i Using project api (Api)
=== Database Setup
i database: ensuring required API firebasedatabase.googleapis.com is enabled...
Error: HTTP Error: 403, Permission denied to get service [firebasedatabase.googleapis.com]
Help Token: ***this is help token***
Check if your service account has the right access rights. Try below.
Follow link
https://console.cloud.google.com/iam-admin/iam?project=api
Find the member that ends with "#appspot.gserviceaccount.com", and click "edit".
Give it "Editor Role", or attach "Firebase Realtime Database Admin".

Firebase init functions returns 403 caller does not have permission

I'm trying to execute "firebase init functions" as a Firebase admin (not owner) in an existing project but receive the following 403 error:
➜ website git:(master) ✗ firebase init functions
######## #### ######## ######## ######## ### ###### ########
## ## ## ## ## ## ## ## ## ## ##
###### ## ######## ###### ######## ######### ###### ######
## ## ## ## ## ## ## ## ## ## ##
## #### ## ## ######## ######## ## ## ###### ########
You're about to initialize a Firebase project in this directory:
/Users/cliff/Work/map/website
Before we get started, keep in mind:
* You are initializing in an existing Firebase project directory
=== 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.
i .firebaserc already has a default project, using my-web-project.
=== Functions Setup
A functions directory will be created in your project with a Node.js
package pre-configured. Functions can be deployed with firebase deploy.
Error: HTTP Error: 403, The caller does not have permission
Having trouble? Try firebase [command] --help
➜ website git:(master) ✗
Any suggestions?
Apparently, if you're NOT the Firebase Owner then you need to have an additional permission added by the Owner as follows:
Error: Missing permissions required for functions deploy. You must have permission iam.serviceAccounts.ActAs on service account my-web-project#appspot.gserviceaccount.com.
To address this error, ask a project Owner to assign your account the "Service Account User" role from this URL:
https://console.cloud.google.com/iam-admin/iam?project=my-web-project
Hope this helps someone in the future.
The output is telling you that the CLI has found an existing project called "my-web-project" using a .firebaserc file in the current directory or one of its parent directories. The error is telling you that the Google user account you are logged in as does not have permission to work with that project.
It's not clear what your intent was in running this command, but you will have to either:
create a new directory and a new project to work with
or grant the current user some sort of access to work with the existing project that the CLI found

" An unexpected error has occurred" after Configure as a single-page app (rewrite all urls to /index.html)? Yes

F:\projects\done>firebase init
######## #### ######## ######## ######## ### ###### ########
## ## ## ## ## ## ## ## ## ## ##
###### ## ######## ###### ######## ######### ###### ######
## ## ## ## ## ## ## ## ## ## ##
## #### ## ## ######## ######## ## ## ###### ########
You're about to initialize a Firebase project in this directory:
F:\projects\done
? Are you ready to proceed? Yes
? Which Firebase CLI features do you want to set up for this folder? Press Space to select features, then Enter to confi
rm your choices. Hosting: Configure and deploy Firebase Hosting sites
=== 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.
? Please select an option: Use an existing project
? Select a default Firebase project for this directory: angular-fireb (angular-fireb)
i Using project angullar-fireba (angullar-fireba)
=== Hosting Setup
Your public directory is the folder (relative to your project directory) that
will contain Hosting assets to be uploaded with firebase deploy. If you
have a build process for your assets, use your build's output directory.
? What do you want to use as your public directory? dist/done/index.html
? Configure as a single-page app (rewrite all urls to /index.html)? Yes
Error: An unexpected error has occurred.
At the question What do you want to use as your public directory? try answering just dist/done.

Firebase Hosting not generate firebase.json

I'm trying to host a website in Firebase Hosting (free plan), I followed the steps but it does not generate the file firebase.json
my steps
1- firebase login
Already logged in as r*****#gmail.com
2- firebase init
######## #### ######## ######## ######## ### ###### ########
## ## ## ## ## ## ## ## ## ## ##
###### ## ######## ###### ######## ######### ###### ######
## ## ## ## ## ## ## ## ## ## ##
## #### ## ## ######## ######## ## ## ###### ########
You're about to initialize a Firebase project in this directory:
C:\Users\Rafael de Azeredo
Before we get started, keep in mind:
You are initializing in an existing Firebase project directory
? Are you ready to proceed? Yes
? Which Firebase CLI features do you want to setup for this folder? Press Space to select features, then Enter to confi
rm your choices. Hosting: Configure and deploy Firebase Hosting sites
=== 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.
i .firebaserc already has a default project, skipping
=== Hosting Setup
Your public directory is the folder (relative to your project directory) that
will contain Hosting assets to be uploaded with firebase deploy. If you
have a build process for your assets, use your build's output directory.
? What do you want to use as your public directory? public
? Configure as a single-page app (rewrite all urls to /index.html)? No
? File public/404.html already exists. Overwrite? No
i Skipping write of public/404.html
? File public/index.html already exists. Overwrite? No
i Skipping write of public/index.html
i Writing configuration info to firebase.json...
i Writing project information to .firebaserc...
Firebase initialization complete!
3- firebase deploy
=== Deploying to 'myhosting-dfe25'...
i deploying database, hosting
i database: checking rules syntax...
+ database: rules syntax for database myhosting-dfe25 is valid
i hosting: preparing public directory for upload...
+ hosting: 2 files uploaded successfully
i database: releasing rules...
+ database: rules for database myhosting-dfe25 released successfully
Deploy complete!
Project Console: https://console.firebase.google.com/project/myhosting-dfe25/overview
Hosting URL: https://myhosting-dfe25.firebaseapp.com
4- https://myhosting-dfe25.firebaseapp.com
but when I open the page I get this message instead of my index.html:
Welcome
Firebase Hosting Setup Complete
You're seeing this because you've successfully setup Firebase Hosting. Now it's time to go build something extraordinary!
Can someone help me please?
Create file firebase.json in root directory in y project:
{
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
}
}
after run command:
firebase use --add
choose y project and deploy:
firebase deploy
That link displays the default index.html file that Firebase puts in the /public folder on your computer. When you deployed the site it has uploaded that default index.html home page.
If you have your own index.html page to upload, either it wasn't in your /public folder or perhaps the install of Firebase overwrote it.
You need to replace that index.html file with the home page you code.

Resources