New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp(). #556
Comments
@maxmumford Adding this statement should get you a reference to firebase object. import * as firebase from 'firebase' |
Thanks for your suggestion but I am already importing firebase with:
The problem is with firebase not being initialised, not with it not being referenced. |
@maxmumford Can you show all of your |
and even a plnkr will be helpful. |
app.module.ts
I tried reproducing with a plnkr but everything worked as expected: https://embed.plnkr.co/o1ImoxSRspawmTxdQ7Hm/ if I WAS able to reproduce the problem on that plnkr, these would be the steps:
If I were to run a similar example in my app, the error message (in my first post in this thread) would show when updateProfile is called... Let me know if you need any more help, I'll provide what I can, but have been struggling for a few hours now to try and reproduce this issue outside of my app... Thanks |
@maxmumford I tried recreating this problem locally, but everything works fine. Also you should see the recommended way to get current user. I modified the code slightly |
Thanks @mukesh51. Usually to get the user's auth state I subscribe to the angularfire auth state change event. I only access the firebase.auth().currentUser object out of necessity for calling updateProfile on it. Hoping @davideast can shed some light on things... |
@maxmumford Just a thought. If everything works as expected on plnkr as well as on my local instance,is it something you would like to try installing everything from scratch Install & Setup to ensure nothing is missing. |
I've started a new project to try to reproduce it locally, I'll spend some On Sat, 24 Sep 2016, 10:29 Mukesh G Chandnani, notifications@github.com
|
@maxmumford: So this works for me (though it's not ideal): Just add "firebase.initializeApp(environment.firebaseConfig)" outside @NgModule in app.module, like this: ` firebase.initializeApp(environment.firebaseConfig); @NgModule({ Again, not ideal, and not sure of the unintended consequences of initializing each of firebase and AF separately. But at least my app is working again. |
Thanks @FoodBuster, I tried your solution and curiously I get the following during the module bootstrap (after manually initing firebase):
This I suppose indicates that some time after the module bootstrap process, the firebase connection is lost or modified. One thing I have been able to rule out is GeoFire - I removed all traces of it from my app and the same error still appears. I'll continue trying to reproduce this issue today... |
…nstall, fill in your firebase creds in app.module.ts, npm start, create a user, login, then click "Set random display name" to reproduce error
I've managed to reproduce this issue in a new, bare project locally, here is a repo with the code: |
I also have the same error I also initialize like the following:
|
EDIT: THIS IS NO LONGER THE RECOMMENDED SOLUTION - SEE COMMENT: As @JimTheMan points out in #585 the solution is to initialise the firebase SDK separately:
For anyone getting this error:
it's down to a missing firebase import in app.module.ts:
😄 Thanks all for your help. |
Adding a second firebase.initializeApp call is no longer the recommended way to access the initialized Firebase object. Safari on iOS was intermittently raising the following exception as a result:
The proper way to go about this is to access AngularFire2's initialized firebase instance like so:
Thanks to @sunlyear for finding this solution, and this SO thread for providing it: |
For me, the error was caused by calling firebase.storage() before firebase had time to initialize (i initialized it in another file), ensure that you only call firebase.someService() inside a method that will be triggered later (after firebase have initialized) |
Hi, I am also getting the same exception.I found one solution but don't would that be effective for you or not. I have initialize the firebase app as . I hope this will help you. |
Confirming that @maxmumford's solution works for Also I'd like to add that as long as you inject the |
Just removing the name of the app:
worked, testing right now. |
As @numerized suggested above, removing the name of the app in the AngularFireModule.initializeApp() method also worked for me. |
AngularFire2 docs don't include it, so do I. |
Wonder what happen to Custom FirebaseApp Names in the docs. |
Yes, when remove custom firebaseApp Names from AngularFireModule.initializeApp(environment.firebase) it's working well again. |
I don't think you must use angularfireModule to initialize the firebase app, Instead run the command outside the constructor and your export class. Right above your export class, add this:
This will work from both |
import modules from angularfire2 in app.module.ts will did the trick. import { AngularFirestoreModule } from 'angularfire2/firestore'; |
Removing the app name works for me you saved me a lot of time @numerized thanks a lot |
My problem is but I defined with a second parameter:
if I remove the second parameter it works fine:
|
@pookdeveloper |
@maxmumford #556 (comment) Thx |
I haven't read any of the other solutions because I solved mine right when I clicked on the link accidentally. If you make a reference to firebase, i.e. |
I resolved this issue by injecting the
|
That saved my day. Thanks. |
After upgrading to 2.0.0-beta.5 and firebase 3.4.0, I can access data through the angularfire2 api without a problem, but when trying to access the firebase object with the following:
firebase.auth().currentUser.updateProfile({...})
I get the following error:
No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp().
This of course indicates that the firebase connection hasn't been initialised, however I am able access data through the angularfire2 api, so I don't know why this would fail...
my package.json:
and in app.module.ts I initialise the af2 connection with:
AngularFireModule.initializeApp(firebaseConfig, firebaseAuthConfigWgs),
any idea what's causing this?
The text was updated successfully, but these errors were encountered: