颤动网络:Firebase:尚未创建Firebase应用程序[默认] [英] Flutter WEB: Firebase: No Firebase App '[DEFAULT]' has been created
本文介绍了颤动网络:Firebase:尚未创建Firebase应用程序[默认]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
将这些依赖项添加到Ffltter Web项目中的pubspec.yaml后
firebase_auth: ^0.18.4+1
cloud_firestore: ^0.14.4
firebase_core: ^0.5.3
并将以下内容添加到我的web/index.html文件
<script src="https://www.gstatic.com/firebasejs/8.2.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.2.1/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.2.1/firebase-firestore.js"></script>
<script>
// Your web app's Firebase configuration
var firebaseConfig = {
apiKey: "xxxxxxxxxxxxxxxxxxxxxxxx",
authDomain: "xxxxxxxxxxxxxxxxxxx",
projectId: "xxxxxxxxxxxxxxxxxxxx",
storageBucket: "xxxxxxxxxxxxxxxxx",
messagingSenderId: "xxxxxxxxxxxxxxxx",
appId: "xxxxxxxxxxxxxxxxxxx"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
</script>
当我尝试重新构建Web应用程序时:
Firebase:尚未创建Firebase应用‘[Default]’-请调用Firebase App.InitializeApp()(app/no-app)。
是否有与此相关的错误? 其他错误:
FirebaseError: Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app).
at Object.f [as app] (https://www.gstatic.com/firebasejs/8.2.1/firebase-app.js:1:16867)
at Object.app$ [as app] (http://localhost:40783/packages/firebase_core_web/src/interop/core.dart.lib.js:32:101)
at initializeApp (http://localhost:40783/packages/firebase_core_web/firebase_core_web.dart.lib.js:81:25)
at initializeApp.next (<anonymous>)
at runBody (http://localhost:40783/dart_sdk.js:37976:34)
at Object._async [as async] (http://localhost:40783/dart_sdk.js:38007:7)
at firebase_core_web.FirebaseCoreWeb.new.initializeApp (http://localhost:40783/packages/firebase_core_web/firebase_core_web.dart.lib.js:74:20)
at initializeApp (http://localhost:40783/packages/firebase_core/firebase_core.dart.lib.js:122:59)
at initializeApp.next (<anonymous>)
at runBody (http://localhost:40783/dart_sdk.js:37976:34)
at Object._async [as async] (http://localhost:40783/dart_sdk.js:38007:7)
at Function.initializeApp (http://localhost:40783/packages/firebase_core/firebase_core.dart.lib.js:121:20)
at main$ (http://localhost:40783/packages/vibeland/widgets/subscription_widget.dart.lib.js:9807:36)
at main$.next (<anonymous>)
at runBody (http://localhost:40783/dart_sdk.js:37976:34)
at Object._async [as async] (http://localhost:40783/dart_sdk.js:38007:7)
at main$ (http://localhost:40783/packages/vibeland/widgets/subscription_widget.dart.lib.js:9805:18)
at main (http://localhost:40783/web_entrypoint.dart.lib.js:34:27)
at main.next (<anonymous>)
at http://localhost:40783/dart_sdk.js:37956:33
at _RootZone.runUnary (http://localhost:40783/dart_sdk.js:37810:58)
at _FutureListener.thenAwait.handleValue (http://localhost:40783/dart_sdk.js:32771:29)
at handleValueCallback (http://localhost:40783/dart_sdk.js:33319:49)
at Function._propagateToListeners (http://localhost:40783/dart_sdk.js:33357:17)
at async._AsyncCallbackEntry.new.callback (http://localhost:40783/dart_sdk.js:33082:27)
at Object._microtaskLoop (http://localhost:40783/dart_sdk.js:38071:13)
at _startMicrotaskLoop (http://localhost:40783/dart_sdk.js:38077:13)
at http://localhost:40783/dart_sdk.js:33574:9
推荐答案
在Main()方法中初始化
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}
这篇关于颤动网络:Firebase:尚未创建Firebase应用程序[默认]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文