Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property 'app' of undefined #2455

Closed
YashMobileFirst opened this issue Apr 28, 2020 · 5 comments
Closed

TypeError: Cannot read property 'app' of undefined #2455

YashMobileFirst opened this issue Apr 28, 2020 · 5 comments
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested.

Comments

@YashMobileFirst
Copy link

YashMobileFirst commented Apr 28, 2020

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 :1:8
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. (http://localhost:61456/dwds/src/injected/client.js:1191:18)``

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

@TahaTesser
Copy link

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

@TahaTesser TahaTesser added the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Apr 28, 2020
@YashMobileFirst
Copy link
Author

YashMobileFirst commented Apr 28, 2020

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 ' flag, or use '-d all' to act on all devices.
[ +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.

#0 throwToolExit (package:flutter_tools/src/base/common.dart:14:3)
#1 RunCommand.validateCommand (package:flutter_tools/src/commands/run.dart:334:7)

#2 FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:740:11)

#3 FlutterCommand.run. (package:flutter_tools/src/runner/flutter_command.dart:657:33)

#4 FlutterCommand.run. (package:flutter_tools/src/runner/flutter_command.dart)
#5 AppContext.run. (package:flutter_tools/src/base/context.dart:150:29)
#6 _rootRun (dart:async/zone.dart:1184:13)
#7 _CustomZone.run (dart:async/zone.dart:1077:19)
#8 _runZoned (dart:async/zone.dart:1619:10)
#9 runZoned (dart:async/zone.dart:1539:10)
#10 AppContext.run (package:flutter_tools/src/base/context.dart:149:18)
#11 FlutterCommand.run (package:flutter_tools/src/runner/flutter_command.dart:647:20)
#12 CommandRunner.runCommand (package:args/command_runner.dart:197:27)
#13 FlutterCommandRunner.runCommand. (package:flutter_tools/src/runner/flutter_command_runner.dart:339:21)
#14 _rootRunUnary (dart:async/zone.dart:1192:38)
#15 _CustomZone.runUnary (dart:async/zone.dart:1085:19)
#16 _FutureListener.handleValue (dart:async/future_impl.dart:141:18)
#17 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:682:45)
#18 Future._propagateToListeners (dart:async/future_impl.dart:711:32)
#19 Future._completeWithValue (dart:async/future_impl.dart:526:5)
#20 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:36:15)
#21 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:303:13)
#22 FlutterVersion.checkFlutterVersionFreshness (package:flutter_tools/src/version.dart)
#23 _rootRunUnary (dart:async/zone.dart:1192:38)
#24 _CustomZone.runUnary (dart:async/zone.dart:1085:19)
#25 _FutureListener.handleValue (dart:async/future_impl.dart:141:18)
#26 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:682:45)
#27 Future._propagateToListeners (dart:async/future_impl.dart:711:32)
#28 Future._completeWithValue (dart:async/future_impl.dart:526:5)
#29 Future._asyncComplete. (dart:async/future_impl.dart:556:7)
#30 _rootRun (dart:async/zone.dart:1184:13)
#31 _CustomZone.run (dart:async/zone.dart:1077:19)
#32 _CustomZone.runGuarded (dart:async/zone.dart:979:7)
#33 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:1019:23)
#34 _microtaskLoop (dart:async/schedule_microtask.dart:43:21)
#35 _startMicrotaskLoop (dart:async/schedule_microtask.dart:52:5)
#36 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#37 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:169:5)

@TahaTesser
Copy link

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

@TahaTesser TahaTesser added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Apr 28, 2020
@YashMobileFirst
Copy link
Author

YashMobileFirst commented Apr 28, 2020

In my project i add firebase web configuration in my index.html but still same result :(

@TahaTesser
Copy link

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

@TahaTesser TahaTesser added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Apr 28, 2020
@firebase firebase locked and limited conversation to collaborators Jul 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested.
Projects
None yet
Development

No branches or pull requests

2 participants