admin管理员组文章数量:1202779
Im trying to implement the firebase SDK to my Flutter web project.
But as i try to start to application the following error appear:
TypeError: Cannot read properties of undefined (reading 'app')
at Object.app$ [as app] (http://localhost:49235/packages/firebase_core_web/src/interop/core.dart.lib.js:31:101)
at initializeApp (http://localhost:49235/packages/firebase_core_web/firebase_core_web.dart.lib.js:108:25)
at initializeApp.next (<anonymous>)
at runBody (http://localhost:49235/dart_sdk.js:39250:34)
at Object._async [as async] (http://localhost:49235/dart_sdk.js:39281:7)
at firebase_core_web.FirebaseCoreWeb.new.initializeApp (http://localhost:49235/packages/firebase_core_web/firebase_core_web.dart.lib.js:85:20)
at initializeApp (http://localhost:49235/packages/firebase_core/firebase_core.dart.lib.js:104:59)
at initializeApp.next (<anonymous>)
at runBody (http://localhost:49235/dart_sdk.js:39250:34)
at Object._async [as async] (http://localhost:49235/dart_sdk.js:39281:7)
at Function.initializeApp (http://localhost:49235/packages/firebase_core/firebase_core.dart.lib.js:103:20)
at main$ (http://localhost:49235/packages/oikos_web_ec/src/widgets/modals/links/delteLink.dart.lib.js:26076:36)
at main$.next (<anonymous>)
at runBody (http://localhost:49235/dart_sdk.js:39250:34)
at Object._async [as async] (http://localhost:49235/dart_sdk.js:39281:7)
at main$ (http://localhost:49235/packages/oikos_web_ec/src/widgets/modals/links/delteLink.dart.lib.js:26074:18)
at main (http://localhost:49235/web_entrypoint.dart.lib.js:39:29)
at main.next (<anonymous>)
at http://localhost:49235/dart_sdk.js:39230:33
at _RootZone.runUnary (http://localhost:49235/dart_sdk.js:39087:58)
at _FutureListener.thenAwait.handleValue (http://localhost:49235/dart_sdk.js:34073:29)
at handleValueCallback (http://localhost:49235/dart_sdk.js:34633:49)
at Function._propagateToListeners (http://localhost:49235/dart_sdk.js:34671:17)
at _Future.new.[_completeWithValue] (http://localhost:49235/dart_sdk.js:34513:23)
at http://localhost:49235/dart_sdk.js:33724:46
at _RootZone.runUnary (http://localhost:49235/dart_sdk.js:39087:58)
at _FutureListener.then.handleValue (http://localhost:49235/dart_sdk.js:34073:29)
at handleValueCallback (http://localhost:49235/dart_sdk.js:34633:49)
at Function._propagateToListeners (http://localhost:49235/dart_sdk.js:34671:17)
at _Future.new.[_completeWithValue] (http://localhost:49235/dart_sdk.js:34513:23)
at async._AsyncCallbackEntry.new.callback (http://localhost:49235/dart_sdk.js:34536:35)
at Object._microtaskLoop (http://localhost:49235/dart_sdk.js:39374:13)
at _startMicrotaskLoop (http://localhost:49235/dart_sdk.js:39380:13)
at http://localhost:49235/dart_sdk.js:34887:9
Thats the script I use in the index.html File
<script type="module">
// Import the functions you need from the SDKs you need
import { initializeApp } from ".10.0/firebase-app.js";
// Your web app's Firebase configuration
const firebaseConfig = {
apiKey: "-----....-----",
authDomain: "-----....-----",
projectId: "-----....-----",
storageBucket: "-----....-----",
messagingSenderId: "-----....-----",
appId: "-----....-----"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
</script>
I also init everything properly at the beginning of the app with:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}
Does someone now how to fix this error?
Im trying to implement the firebase SDK to my Flutter web project.
But as i try to start to application the following error appear:
TypeError: Cannot read properties of undefined (reading 'app')
at Object.app$ [as app] (http://localhost:49235/packages/firebase_core_web/src/interop/core.dart.lib.js:31:101)
at initializeApp (http://localhost:49235/packages/firebase_core_web/firebase_core_web.dart.lib.js:108:25)
at initializeApp.next (<anonymous>)
at runBody (http://localhost:49235/dart_sdk.js:39250:34)
at Object._async [as async] (http://localhost:49235/dart_sdk.js:39281:7)
at firebase_core_web.FirebaseCoreWeb.new.initializeApp (http://localhost:49235/packages/firebase_core_web/firebase_core_web.dart.lib.js:85:20)
at initializeApp (http://localhost:49235/packages/firebase_core/firebase_core.dart.lib.js:104:59)
at initializeApp.next (<anonymous>)
at runBody (http://localhost:49235/dart_sdk.js:39250:34)
at Object._async [as async] (http://localhost:49235/dart_sdk.js:39281:7)
at Function.initializeApp (http://localhost:49235/packages/firebase_core/firebase_core.dart.lib.js:103:20)
at main$ (http://localhost:49235/packages/oikos_web_ec/src/widgets/modals/links/delteLink.dart.lib.js:26076:36)
at main$.next (<anonymous>)
at runBody (http://localhost:49235/dart_sdk.js:39250:34)
at Object._async [as async] (http://localhost:49235/dart_sdk.js:39281:7)
at main$ (http://localhost:49235/packages/oikos_web_ec/src/widgets/modals/links/delteLink.dart.lib.js:26074:18)
at main (http://localhost:49235/web_entrypoint.dart.lib.js:39:29)
at main.next (<anonymous>)
at http://localhost:49235/dart_sdk.js:39230:33
at _RootZone.runUnary (http://localhost:49235/dart_sdk.js:39087:58)
at _FutureListener.thenAwait.handleValue (http://localhost:49235/dart_sdk.js:34073:29)
at handleValueCallback (http://localhost:49235/dart_sdk.js:34633:49)
at Function._propagateToListeners (http://localhost:49235/dart_sdk.js:34671:17)
at _Future.new.[_completeWithValue] (http://localhost:49235/dart_sdk.js:34513:23)
at http://localhost:49235/dart_sdk.js:33724:46
at _RootZone.runUnary (http://localhost:49235/dart_sdk.js:39087:58)
at _FutureListener.then.handleValue (http://localhost:49235/dart_sdk.js:34073:29)
at handleValueCallback (http://localhost:49235/dart_sdk.js:34633:49)
at Function._propagateToListeners (http://localhost:49235/dart_sdk.js:34671:17)
at _Future.new.[_completeWithValue] (http://localhost:49235/dart_sdk.js:34513:23)
at async._AsyncCallbackEntry.new.callback (http://localhost:49235/dart_sdk.js:34536:35)
at Object._microtaskLoop (http://localhost:49235/dart_sdk.js:39374:13)
at _startMicrotaskLoop (http://localhost:49235/dart_sdk.js:39380:13)
at http://localhost:49235/dart_sdk.js:34887:9
Thats the script I use in the index.html File
<script type="module">
// Import the functions you need from the SDKs you need
import { initializeApp } from "https://www.gstatic.com/firebasejs/8.10.0/firebase-app.js";
// Your web app's Firebase configuration
const firebaseConfig = {
apiKey: "-----....-----",
authDomain: "-----....-----",
projectId: "-----....-----",
storageBucket: "-----....-----",
messagingSenderId: "-----....-----",
appId: "-----....-----"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
</script>
I also init everything properly at the beginning of the app with:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}
Does someone now how to fix this error?
Share Improve this question edited Sep 6, 2021 at 15:19 Frank van Puffelen 599k84 gold badges888 silver badges858 bronze badges Recognized by Google Cloud Collective asked Sep 6, 2021 at 15:15 user14085420user14085420 1- 1 I followed this guide and works fine for me. – Peter Koltai Commented Sep 6, 2021 at 15:45
4 Answers
Reset to default 7I was having this issue and solved this changing the script in the index.html to this
<script src="https://www.gstatic.com/firebasejs/8.10.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.10.0/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.10.0/firebase-firestore.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.10.0/firebase-storage.js"></script>
<script>
// Import the functions you need from the SDKs you need
// 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
const firebaseConfig = {
apiKey: "...",
authDomain: "...",
projectId: "...",
storageBucket: "...",
messagingSenderId: "...",
appId: "..."
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
</script>
in current version only add this imports
import firebase from "firebase/compat/app";
import "firebase/compat/auth";
import "firebase/compat/firestore";
in the head the firebase settings file
Use this:
https://www.gstatic.com/firebasejs/8.6.1/firebase-app.js
in place of
https://www.gstatic.com/firebasejs/8.10.0/firebase-app.js
More info
I'm experiencing a similar issue with Firebase 9. Downgrade to 8.x and see if it's resolved.
本文标签: javascriptCannot read properties of undefined (reading 39app39)Stack Overflow
版权声明:本文标题:javascript - Cannot read properties of undefined (reading 'app') - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738658791a2105295.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论