invertase / flutterfire_cli

A CLI to help with using FlutterFire in your Flutter applications.
Apache License 2.0
173 stars 49 forks source link

[bug]: flutterfire configure Unhandled exception: type 'Null' is not a subtype of type 'String' #171

Closed Ziron-hub closed 1 month ago

Ziron-hub commented 1 year ago

Is there an existing issue for this?

CLI Version

0.2.7

Firebase Tools version

11.25.2

Flutter Doctor Output

flutter doctor -v [✓] Flutter (Channel stable, 3.7.8, on Ubuntu 20.04.6 LTS 5.15.0-69-generic, locale pt_BR.UTF-8) • Flutter version 3.7.8 on channel stable at /home/aquila020/snap/flutter/common/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 90c64ed42b (12 days ago), 2023-03-21 11:27:08 -0500 • Engine revision 9aa7816315 • Dart version 2.19.5 • DevTools version 2.20.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1) • Android SDK at /home/aquila020/Library/Android/Sdk • Platform android-33, build-tools 33.0.1 • ANDROID_SDK_ROOT = /home/aquila020/Library/Android/Sdk • Java binary at: /snap/android-studio/current/android-studio/jre/bin/java • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866) • All Android licenses accepted.

[✓] Chrome - develop for the web • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop • clang version 10.0.0-4ubuntu1 • cmake version 3.16.3 • ninja version 1.10.0 • pkg-config version 0.29.1

[✓] Android Studio (version 4.0) • Android Studio at /home/aquila020/android-studio • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

[✓] Android Studio (version 2021.3) • Android Studio at /snap/android-studio/125/android-studio • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[✓] Android Studio • Android Studio at /snap/android-studio/current/android-studio • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • android-studio-dir = /snap/android-studio/current/android-studio • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[✓] Android Studio • Android Studio at /opt/android-studio • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)

[✓] VS Code • VS Code at /snap/code/current • Flutter extension version 3.60.0

[✓] Connected device (2 available) • Linux (desktop) • linux • linux-x64 • Ubuntu 20.04.6 LTS 5.15.0-69-generic • Chrome (web) • chrome • web-javascript • Google Chrome 111.0.5563.146

[✓] HTTP Host Availability • All required HTTP hosts are available

• No issues found!

Description

I'm trying to use firestore from firebase and for that I need to configure firebase in my flutter project, but when I get to the step of using the command "flutterfire configure" it gives this error.

Steps to reproduce

  1. Install CLI of firebase
  2. Use this command: "firebase login" and log in your firebase account
  3. Install flutterfire: "dart pub global activate flutterfire_cli"
  4. And run this: "flutterfire configure"

Expected behavior

I hope this creates a firebase config file.

Screenshots

Captura de tela de 2023-04-02 19-08-12

Additional context and comments

No response

kwek20 commented 1 year ago

Also mentioned here. I have the same issue https://github.com/firebase/flutterfire/issues/7915

I have tried to do this with the fluffychat project, but the error persists.

However, making a new project on the C drive(instead of I), with a valid dart folder name (test for example),i received a new error:

⠹ Fetching available Firebase projects...
Unhandled exception:
FormatException: Unexpected character (at character 1)
#
^

#0      _ChunkedJsonParser.fail (dart:convert-patch/convert_patch.dart:1383:5)
#1      _ChunkedJsonParser.parseNumber (dart:convert-patch/convert_patch.dart:1250:9)
#2      _ChunkedJsonParser.parse (dart:convert-patch/convert_patch.dart:915:22)
#3      _parseJson (dart:convert-patch/convert_patch.dart:35:10)
#4      JsonDecoder.convert (dart:convert/json.dart:612:36)
#5      runFirebaseCommand (package:flutterfire_cli/src/firebase.dart:95:25)
<asynchronous suspension>
#6      getProjects (package:flutterfire_cli/src/firebase.dart:114:20)
<asynchronous suspension>
#7      ConfigCommand._selectFirebaseProject (package:flutterfire_cli/src/commands/config.dart:300:24)
<asynchronous suspension>
#8      ConfigCommand.run (package:flutterfire_cli/src/commands/config.dart:390:37)
<asynchronous suspension>
#9      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#10     main (file:///C:/Users/Brord/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutterfire_cli-0.2.7/bin/flutterfire.dart:57:5)
<asynchronous suspension>

This is done using Powershell on windows. Once i used WSL on the new project, the command succeeded. However, it still did not succeed in the fluffychat project. Maybe its out of date or invalid configuration files

russellwheatley commented 1 year ago

Could you show me the pubspec.yaml file you are using? It appears you don't have a version for one of your dependencies but hard to confirm without seeing the contents of your pubspec.yaml.

krille-chan commented 11 months ago

Hello, I'm the maintainer of FluffyChat and have the same problem. The content of the pubspec.yaml file I have tried this with is:

name: fluffychat
description: Chat with your friends.
publish_to: none
# On version bump also increase the build number for F-Droid
version: 1.16.0+3523

environment:
  sdk: ">=3.0.0 <4.0.0"

dependencies:
  adaptive_dialog: ^2.0.0
  animations: ^2.0.8
  archive: ^3.4.9
  async: ^2.11.0
  badges: ^3.1.2
  blurhash_dart: ^1.2.1
  callkeep: ^0.3.2
  chewie: ^1.7.1
  collection: ^1.17.2
  cupertino_icons: any
  desktop_drop: ^0.4.4
  desktop_notifications: ^0.6.3
  device_info_plus: ^9.1.0
  dynamic_color: ^1.6.8
  emoji_picker_flutter: ^1.6.3
  emoji_proposal: ^0.0.1
  emojis: ^0.9.9
  file_picker: ^6.1.1
  firebase_core: ^2.24.2
  firebase_messaging: ^14.7.9
  flutter:
    sdk: flutter
  flutter_app_badger: ^1.5.0
  flutter_blurhash: ^0.8.2
  flutter_cache_manager: ^3.3.0
  flutter_foreground_task: ^6.0.0+1
  flutter_highlighter: ^0.1.1
  flutter_html: ^3.0.0-beta.2
  flutter_html_table: ^3.0.0-beta.2
  flutter_linkify: ^6.0.0
  flutter_local_notifications: ^16.1.0
  flutter_localizations:
    sdk: flutter
  flutter_map: ^4.0.0
  flutter_math_fork: ^0.7.2
  flutter_olm: 1.3.2 # Keep in sync with scripts/prepare-web.sh ! 1.4.0 does currently not build on Android
  flutter_openssl_crypto: ^0.3.0
  flutter_ringtone_player: ^4.0.0+2
  flutter_secure_storage: ^9.0.0
  flutter_typeahead: ^4.8.0
  flutter_web_auth_2: ^3.0.4
  flutter_webrtc: ^0.9.46
  future_loading_dialog: ^0.3.0
  geolocator: ^7.6.2
  go_router: ^12.1.1
  hive: ^2.2.3
  hive_flutter: ^1.1.0
  http: ^0.13.6
  image_picker: ^1.0.0
  intl: any
  just_audio: ^0.9.30
  keyboard_shortcuts: ^0.1.4
  latlong2: ^0.8.1
  linkify: ^5.0.0
  matrix: ^0.25.0
  matrix_homeserver_recommendations: ^0.3.0
  native_imaging: ^0.1.0
  package_info_plus: ^4.0.0
  pasteboard: ^0.2.0
  path_provider: ^2.0.9
  permission_handler: ^11.0.1
  provider: ^6.0.2
  punycode: ^1.0.0
  qr_code_scanner: ^1.0.0
  qr_flutter: ^4.0.0
  receive_sharing_intent: ^1.4.5
  record: 4.4.4 # Upgrade to 5 currently breaks playing on iOS
  scroll_to_index: ^3.0.1
  share_plus: ^7.2.1
  shared_preferences: ^2.2.0 # Pinned because https://github.com/flutter/flutter/issues/118401
  slugify: ^2.0.0
  sqflite: ^2.3.0
  sqflite_common_ffi: ^2.3.0+4
  sqflite_sqlcipher: ^2.2.1
  swipe_to_action: ^0.2.0
  tor_detector_web: ^1.1.0
  uni_links: ^0.5.1
  unifiedpush: ^5.0.1
  universal_html: ^2.2.4
  url_launcher: ^6.2.1
  vibration: ^1.8.3
  video_compress: ^3.1.1
  video_player: ^2.8.1
  wakelock_plus: ^1.1.3
  webrtc_interface: ^1.0.13

dev_dependencies:
  dart_code_metrics: ^5.7.5
  flutter_lints: ^3.0.0
  flutter_native_splash: ^2.0.3+1
  flutter_test:
    sdk: flutter
  import_sorter: ^4.6.0
  integration_test:
    sdk: flutter
  msix: ^3.6.2
  translations_cleaner: ^0.0.5

flutter_native_splash:
  color: "#ffffff"
  color_dark: "#000000"
  image: "assets/info-logo.png"

flutter:
  generate: true
  uses-material-design: true
  assets:
    - assets/
    - assets/sounds/
    - assets/js/
    - assets/js/package/

  fonts:
    - family: Roboto
      fonts:
        - asset: fonts/Roboto/Roboto-Regular.ttf
        - asset: fonts/Roboto/Roboto-Italic.ttf
          style: italic
        - asset: fonts/Roboto/Roboto-Bold.ttf
          weight: 700
    - family: RobotoMono
      fonts:
        - asset: fonts/Roboto/RobotoMono-Regular.ttf
    - family: NotoEmoji
      fonts:
        - asset: fonts/NotoEmoji/NotoColorEmoji.ttf

msix_config:
  display_name: FluffyChat
  publisher_display_name: FluffyChat
  publisher: CN=FluffyChat, O=Head of bad integration tests, L=Matrix, S=Internet, C=EU
  identity_name: chat.fluffy.fluffychat
  logo_path: assets\logo.png
  capabilities: internetClient, location, microphone, webcam
  protocol_activation: https
  app_uri_handler_hosts: fluffychat.im, matrix.to
  execution_alias: fluffychat
  sign_msix: false
  install_certificate: false

dependency_overrides:
  # Until https://github.com/mogol/flutter_secure_storage/issues/616 is fixed
  flutter_secure_storage_linux: 1.1.3
  geolocator_android:
    hosted:
      name: geolocator_android
      url: https://hanntech-gmbh.gitlab.io/free2pass/flutter-geolocator-floss
  # waiting for null safety
  # Upstream pull request: https://github.com/AntoineMarcel/keyboard_shortcuts/pull/13
  keyboard_shortcuts:
    git:
      url: https://github.com/TheOneWithTheBraid/keyboard_shortcuts.git
      ref: null-safety
  # blocked upgrade of package_info_plus for null safety
  # https://github.com/creativecreatorormaybenot/wakelock/pull/203
  wakelock_windows:
    git:
      url: https://github.com/chandrabezzo/wakelock.git
      ref: main
      path: wakelock_windows/

The error message differs when I remove this override:


  geolocator_android:
    hosted:
      name: geolocator_android
      url: https://hanntech-gmbh.gitlab.io/free2pass/flutter-geolocator-floss

So maybe there is a bug in the pubspec package which occurs when using hosted dependencies?

feinstein commented 9 months ago

If this helps, I am getting this error on iOS:

13 warnings generated.
    Unhandled exception:
    type 'Null' is not a subtype of type 'String' in type cast
    #0      BundleServiceFile.run (package:flutterfire_cli/src/commands/bundle_service_file.dart:99:67)
    <asynchronous suspension>
    #1      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
    <asynchronous suspension>
    #2      main (file:///Users/andrew/.pub-cache/hosted/pub.dev/flutterfire_cli-0.3.0-dev.19/bin/flutterfire.dart:63:5)
    <asynchronous suspension>
    Command PhaseScriptExecution failed with a nonzero exit code
russellwheatley commented 9 months ago

Not the same issue, @feinstein. This issue if for general release (0.2.7). Look at the stack trace. Your exception is coming from here: https://github.com/invertase/flutterfire_cli/blob/main/packages/flutterfire_cli/lib/src/commands/bundle_service_file.dart#L99 which means your firebase.json doesn't have the file output property in the build configuration map for whatever app you're trying to build.

feinstein commented 9 months ago

@russellwheatley thats weird because I am not changing the file, but changing the CLI version makes the error go away.

russellwheatley commented 9 months ago

What do you mean changing the CLI version?

feinstein commented 9 months ago

@russellwheatley for example, right now I got that error, and I was running version 0.3.0-dev.19, so I did flutter pub global activate flutterfire_cli 0.3.0-dev.16, and the error didn't appear during a new build.

I was using 0.3.0-dev.16, but I remember I was gettitng this error in my CICD machine, so I updated it to dev.19 and it worked. But now I am getting errors on dev.19 in my machine, and going to dev.16 works.

The Firebase json file was downloaded by the CLI, so it shouldn't have any fields missing.

russellwheatley commented 8 months ago

@feinstein - That seems odd. The only thing I can think might cause this is if you ran flutterfire configure using 0.3.0-dev.16, and on subsequent runs, you used 0.3.0-dev.19 and possibly vice versa. If you want to post your firebase.json file with the values missing (i.e. empty strings), it might be a property that has changed between versions which is why it is showing as null.

feinstein commented 8 months ago

That's a good theory. I will try to replicate and let you know.

EclipseAndrey commented 8 months ago

@feinstein, does this solve your problem? I have the same message. But firebase.json looks fine

Unhandled exception:
type 'Null' is not a subtype of type 'String' in type cast
#0      BundleServiceFile.run (package:flutterfire_cli/src/commands/bundle_service_file.dart:100:46)
<asynchronous suspension>
#1      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#2      main (file:///Users/user/.pub-cache/hosted/pub.dev/flutterfire_cli-0.3.0-dev.16/bin/flutterfire.dart:63:5)
<asynchronous suspension>
Command PhaseScriptExecution failed with a nonzero exit code
feinstein commented 8 months ago

I wasn't able to stop to test it since then. Can you post your json file here?

russellwheatley commented 8 months ago

@EclipseAndrey - Might be worth updating to the latest CLI as well. You're using dev.16, we are now on dev.21.

feinstein commented 8 months ago

@russellwheatley I know we are dealing with dev versions, but do the production versions account for changes in the json structure between versions, and migrate the json accordingly?

russellwheatley commented 8 months ago

The latest general release has no concept of firebase.json structure, only dev versions.

bsutton commented 5 months ago

So for clarity, the original posted exception is caused by an externally hosted dependency:

e.g.

dependencies:
   sms_advanced: # ^1.1.0
     hosted: https://onepub.dev/api/jbbxpsdavu/ 

Commenting out the dependency and running flutterfire_cli configure will allow to side step the exception, you can then add the dependency back to your project.

The pubspec package is now deprecated so should probably be replaced with either: pubspec_parse - looks like it is supported by the dart team but the api is still limited. pubspec_manager - a complete api but supported by a single developer - me :)

If you use pubspec_manager I'm happy to give you a hand with the migration.

github-actions[bot] commented 1 month ago

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.