1

first I'm sorry, this is the first time I ask a question on a forum and I don't speak english very well... I'm working on an application with Ionic 3 and I'm getting this error when I try to use firebase :

Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app)

Here are my files :

App.module.ts :

import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';

import { AngularFireModule } from 'angularfire2';
import { AngularFireAuthModule } from 'angularfire2/auth';

import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
import {TabsPage} from "../pages/tabs/tabs";
import {ListPage} from "../pages/list/list";
import {AuthPage} from "../pages/auth/auth";
import {AuthService} from "../Services/Authentification/auth.service";
import {FIREBASE_CONFIG} from "./app.firebase.config";

    @NgModule({
      declarations: [
        MyApp,
        HomePage,
        TabsPage,
        ListPage,
        AuthPage,
      ],
      imports: [
        BrowserModule,
        IonicModule.forRoot(MyApp),
        AngularFireModule.initializeApp(FIREBASE_CONFIG),
        AngularFireAuthModule,
      ],
      bootstrap: [IonicApp],
      entryComponents: [
        MyApp,
        HomePage,
        TabsPage,
        ListPage,
        AuthPage,
      ],
      providers: [
        StatusBar,
        SplashScreen,
        {provide: ErrorHandler, useClass: IonicErrorHandler},
        AuthService,
      ]
    })
    export class AppModule {}

app.firebase.config :

export const FIREBASE_CONFIG = {

  apiKey: "...",
  authDomain: "...",
  databaseURL: "...",
  projectId: "...",
  storageBucket: "...",
  messagingSenderId: "..."

};

I've search solutions on others forum but nothing worked. If you need more information tell me

Arash
  • 1,692
  • 5
  • 21
  • 36

1 Answers1

5

I'm guessing that you might have a problem with the path of the file to your Firebase_config definition. I moved away from angularFire a while back, but I remember that the initialization was similar. Here's my app.module.ts file below... so, perhaps this is something you can try:

import { NgModule } from '@angular/core'; 
import { BrowserModule } from '@angular/platform-browser'; 
import { RouterModule, RouteReuseStrategy, Routes } from '@angular/router'; 
import { IonicModule, IonicRouteStrategy } from '@ionic/angular'; 
import { SplashScreen } from '@ionic-native/splash-screen/ngx'; 
import { StatusBar } from '@ionic-native/status-bar/ngx'; 
import { AppComponent } from './app.component'; 
import { AppRoutingModule } from './app-routing.module';
import * as firebase from 'firebase';
    
      // Initialize Firebase
      export const config = {
        apiKey: "CENSORED",
        authDomain: "CENSORED.firebaseapp.com",
        databaseURL: "https://CENSORED.firebaseio.com",
        projectId: "CENSORED-fffff",
        storageBucket: "sCENSORED-fffff.appspot.com",
        messagingSenderId: "CENSORED"   
      };
      firebase.initializeApp(config);     <--------initialize here
    


@NgModule({
  declarations: [
    AppComponent, 
    LoginFormComponent, 
   ],
  entryComponents: [
  ],
  imports: [
    BrowserModule, 
    IonicModule.forRoot(),    <----No mention of firebase down here
    AppRoutingModule,
    IonicStorageModule.forRoot(),
  ],
  providers: [
    AuthenticationService,
    StatusBar,
    SplashScreen,
    { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
  ],
  bootstrap: [AppComponent]
})
export class AppModule {}
William Hou
  • 1,251
  • 14
  • 17
William Terrill
  • 3,484
  • 4
  • 31
  • 41
  • I think it's working, I have now the error : "The password is invalid or the user does not have a password." but I'm sure that the password I enter is the good one. I have an other appli with the same firebase project is it a problem ? – Nicolas Desclaux Oct 02 '18 at 12:24
  • If you're sure that the password is correct, then make sure that you're accessing the right firebase authentication database. In order to do that, I'd delete the user that you're trying to access, and make sure that the error changes to "the user does not exist" If it doesn't change, then I'd check the initialization config. – William Terrill Oct 02 '18 at 13:33
  • Everything is working now, I had an error in my html and then didn't get back the password value... Thanks for your help and sorry for my english :p !! – Nicolas Desclaux Oct 02 '18 at 17:19
  • adding comment to say that the import has been moved to `firebase/app` otherwise lifesaver comment. 10/10 would recommend moving away from angularfire – sinanspd Jul 25 '23 at 20:45