【问题标题】:initializeApp firebase issueinitializeApp firebase 问题
【发布时间】:2022-01-22 07:53:12
【问题描述】:

expo 托管应用用户(最新版本)...我们有这个 firebase.js 文件,但无法弄清楚为什么我们一直看到错误

需要看看这个文件有什么问题......如果有的话 - 这让我发疯了!感谢任何反馈/提示

错误: 12:03 错误:您试图通过调用 firebase.app() 来使用未安装在您的 Android 项目上的 firebase 模块。

// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app"
import { getFirestore } from '@react-native-firebase/firestore';
import Constants from "expo-constants"
import "@react-native-firebase/auth"
// Should not be used elsewhere in the project

// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries

// Your web app's Firebase configuration -- from firebase console
// For Firebase JS SDK v7.20.0 and later, measurementId is optional

const firebaseConfig = {
apiKey: Constants.manifest.extra.apiKey,
authDomain: Constants.manifest.extra.authDomain,
databaseURL: Constants.manifest.extra.databaseURL,
projectId: Constants.manifest.extra.projectId,
storageBucket: Constants.manifest.extra.storageBucket,
messagingSenderId: Constants.manifest.extra.messagingSenderId,
appId: Constants.manifest.extra.appId,
measurementId: Constants.manifest.extra.measurementId,
}

// Initialize Firebase
const Firebase = initializeApp(firebaseConfig)
const firestore = getFirestore();

export default [Firebase, firestore]

【问题讨论】:

    标签: firebase react-native expo


    【解决方案1】:

    如果您使用 SDK 确保您拥有所使用的每个 Firebase 服务所需的所有 SDK,

    最重要的是应该首先列出的应用SDK

    其他

    导入firebase并先初始化

    这个页面应该可以解决你的问题:https://firebase.google.com/docs/web/alt-setup#node.js-apps

    【讨论】:

    • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
    • 谢谢!我注意到我在我的 app.tsx 文件中导入了 firebase,当我删除它时解决了这个错误
    猜你喜欢
    • 2019-03-01
    • 2017-07-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-12
    • 2021-12-11
    相关资源
    最近更新 更多