whenever i run the project on chrome it shows me and i just add cloud_firestore to pubspec.yaml
TypeError: Cannot read property 'app' of undefined
at Object.app$ [as app] (http://localhost:61456/packages/firebase/src/top_level.dart.lib.js:72:56)
at new cloud_firestore_web.FirestoreWeb.new (http://localhost:61456/packages/cloud_firestore_web/src/write_batch_web.dart.lib.js:793:57)
at Function.registerWith (http://localhost:61456/packages/cloud_firestore_web/src/write_batch_web.dart.lib.js:738:71)
at Object.registerPlugins (http://localhost:61456/packages/fluttertestwebapp/generated_plugin_registrant.dart.lib.js:13:38)
at main$ (http://localhost:61456/web_entrypoint.dart.lib.js:15:35)
at main$.next (
at runBody (http://localhost:61456/dart_sdk.js:43130:34)
at Object._async [as async] (http://localhost:61456/dart_sdk.js:43158:7)
at main$ (http://localhost:61456/web_entrypoint.dart.lib.js:14:18)
at
at Object.runMain (http://localhost:61456/dwds/src/injected/client.js:8343:15)
at http://localhost:61456/dwds/src/injected/client.js:22338:19
at _wrapJsFunctionForAsync_closure.$protected (http://localhost:61456/dwds/src/injected/client.js:3636:15)
at _wrapJsFunctionForAsync_closure.call$2 (http://localhost:61456/dwds/src/injected/client.js:10851:12)
at Object._asyncStartSync (http://localhost:61456/dwds/src/injected/client.js:3600:20)
at main__closure1.$call$body$main__closure (http://localhost:61456/dwds/src/injected/client.js:22350:16)
at main__closure1.call$1 (http://localhost:61456/dwds/src/injected/client.js:22282:19)
at StaticClosure._rootRunUnary [as call$2$5] (http://localhost:61456/dwds/src/injected/client.js:3958:16)
at _CustomZone.runUnary$2$2 (http://localhost:61456/dwds/src/injected/client.js:12167:39)
at _CustomZone.runUnaryGuarded$1$2 (http://localhost:61456/dwds/src/injected/client.js:12095:14)
at _ControllerSubscription._sendData$1 (http://localhost:61456/dwds/src/injected/client.js:11645:19)
at _DelayedData.perform$1 (http://localhost:61456/dwds/src/injected/client.js:11799:59)
at _PendingEvents_schedule_closure.call$0 (http://localhost:61456/dwds/src/injected/client.js:11848:14)
at Object._microtaskLoop (http://localhost:61456/dwds/src/injected/client.js:3801:21)
at StaticClosure._startMicrotaskLoop (http://localhost:61456/dwds/src/injected/client.js:3807:11)
at _AsyncRun__initializeScheduleImmediate_internalCallback.call$1 (http://localhost:61456/dwds/src/injected/client.js:10723:9)
at invokeClosure (http://localhost:61456/dwds/src/injected/client.js:1172:26)
at MutationObserver.
My pubspec.yaml
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.3
cloud_firestore:
dev_dependencies:
flutter_test:
sdk: flutter
Hi @YashMobileFirst
can you please provide your flutter doctor -v and flutter run --verbose?
Also, to better address the issue, would be helpful if you could post a minimal code sample to reproduce the problem
Thank you
i just create a new flutter project and changes i made is add cloud_firestore to pubspec.yaml
flutter doctor -v
[✓] Flutter (Channel dev, v1.18.0-8.0.pre, on Mac OS X 10.13.6 17G66, locale en-IN)
• Flutter version 1.18.0-8.0.pre at /Users/mobilefirst/Downloads/flutter
• Framework revision e0c63cd35e (4 days ago), 2020-04-23 22:29:01 -0400
• Engine revision d2ec21221e
• Dart version 2.9.0 (build 2.9.0-3.0.dev b0d35855d8)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/mobilefirst/Library/Android/sdk
• Platform android-29, build-tools 29.0.2
• ANDROID_HOME = /Users/mobilefirst/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
• All Android licenses accepted.
[✗] Xcode - develop for iOS and macOS
✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
Download at: https://developer.apple.com/xcode/download/
Or install Xcode via the App Store.
Once installed, run:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch
✗ CocoaPods not installed.
CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/platform-plugins
To install:
sudo gem install cocoapods
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 3.6)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 44.0.2
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
[✓] Connected device (3 available)
• macOS • macOS • darwin-x64 • Mac OS X 10.13.6 17G66
• Web Server • web-server • web-javascript • Flutter Tools
• Chrome • chrome • web-javascript • Google Chrome 81.0.4044.122
flutter run --verbose
[ +19 ms] executing: [/Users/mobilefirst/Downloads/flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[ +109 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[ +4 ms] e0c63cd35e15e407a80dc44281cc392535fcce25
[ +2 ms] executing: [/Users/mobilefirst/Downloads/flutter/] git tag --contains HEAD
[ +937 ms] Exit code 0 from: git tag --contains HEAD
[ +1 ms] 1.18.0-8.0.pre
[ +23 ms] executing: [/Users/mobilefirst/Downloads/flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[ +33 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[ +1 ms] origin/dev
[ ] executing: [/Users/mobilefirst/Downloads/flutter/] git ls-remote --get-url origin
[ +16 ms] Exit code 0 from: git ls-remote --get-url origin
[ ] https://github.com/flutter/flutter.git
[ +137 ms] executing: [/Users/mobilefirst/Downloads/flutter/] git rev-parse --abbrev-ref HEAD
[ +34 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[ +1 ms] dev
[ +21 ms] executing: sw_vers -productName
[ +82 ms] Exit code 0 from: sw_vers -productName
[ +2 ms] Mac OS X
[ ] executing: sw_vers -productVersion
[ +26 ms] Exit code 0 from: sw_vers -productVersion
[ +1 ms] 10.13.6
[ ] executing: sw_vers -buildVersion
[ +25 ms] Exit code 0 from: sw_vers -buildVersion
[ +1 ms] 17G66
[ +127 ms] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[ +9 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ +36 ms] executing: /Users/mobilefirst/Library/Android/sdk/platform-tools/adb devices -l
[ +10 ms] executing: /usr/bin/xcode-select --print-path
[ +22 ms] Exit code 0 from: /usr/bin/xcode-select --print-path
[ +1 ms] /Library/Developer/CommandLineTools
[ +2 ms] executing: /usr/bin/xcodebuild -version
[ +6 ms] Exit code 1 from: /usr/bin/xcodebuild -version
[ ] xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
[ ] Xcode not found. Run 'flutter doctor' for more information.
[ +2 ms] executing: /usr/bin/xcodebuild -version
[ +6 ms] Exit code 1 from: /usr/bin/xcodebuild -version
[ ] xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
[ +63 ms] List of devices attached
[ +11 ms] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[ +10 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[ +3 ms] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ +16 ms] executing: /usr/bin/xcodebuild -version
[ +5 ms] Exit code 1 from: /usr/bin/xcodebuild -version
[ ] xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
[ +85 ms] More than one device connected; please specify a device with the '-d
[ +380 ms] macOS • macOS • darwin-x64 • Mac OS X 10.13.6 17G66
[ +2 ms] Web Server • web-server • web-javascript • Flutter Tools
[ ] Chrome • chrome • web-javascript • Google Chrome 81.0.4044.122
[ +24 ms] "flutter run" took 750ms.
Hi @YashMobileFirst
Just tested the issue and you're missing firebase web configuration in your index.html file
<script src="https://www.gstatic.com/firebasejs/7.5.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.5.0/firebase-firestore.js"></script>
<script>
// TODO: Replace the following with your app's Firebase project configuration.
// See: https://support.google.com/firebase/answer/7015592
var firebaseConfig = {
apiKey: "...",
authDomain: "[YOUR_PROJECT].firebaseapp.com",
databaseURL: "https://[YOUR_PROJECT].firebaseio.com",
projectId: "[YOUR_PROJECT]",
storageBucket: "[YOUR_PROJECT].appspot.com",
messagingSenderId: "...",
appId: "1:...:web:...",
measurementId: "G-..."
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
</script>
<script src="main.dart.js" type="application/javascript"></script>
Please follow this guide
Thank you
In my project i add firebase web configuration in my index.html but still same result :(
I just tested the issue and adding the proper configuration solved the issue
Can you post your index.html by replacing your credentials
Thank you
Most helpful comment
Hi @YashMobileFirst
Just tested the issue and you're missing firebase web configuration in your index.html file
Please follow this guide
Thank you