Firebase:未创建Firebase应用程序'[DEFAULT]'-调用Firebase App.initializeApp()(app/no-app) [英] Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app)

查看:93
本文介绍了Firebase:未创建Firebase应用程序'[DEFAULT]'-调用Firebase App.initializeApp()(app/no-app)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,很抱歉,这是我第一次在论坛上提问,而且英语说得不太好...我正在使用Ionic 3开发应用程序,尝试使用Firebase时出现此错误:

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:未创建Firebase应用程序'[DEFAULT]'-调用Firebase App.initializeApp()(app/no-app)

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

这是我的文件:

App.module.ts:

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:

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

推荐答案

我猜想您的Firebase_config定义的文件路径可能有问题.我离开了angularFire了一段时间,但是我记得初始化是相似的.这是下面的我的app.module.ts文件...因此,也许您可​​以尝试以下操作:

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 {}

这篇关于Firebase:未创建Firebase应用程序'[DEFAULT]'-调用Firebase App.initializeApp()(app/no-app)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆