invertase / flutterfire_cli

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

[bug]: FormatException when JSON is too long #144

Closed leo-neon closed 8 months ago

leo-neon commented 1 year ago

Is there an existing issue for this?

CLI Version

0.2.7

Firebase Tools version

11.20.0

Flutter Doctor Output

[✓] Flutter (Channel stable, 3.3.6, on macOS 13.1 22C65 darwin-arm (Rosetta), locale en-DE) • Flutter version 3.3.6 on channel stable at ... • Upstream repository https://github.com/flutter/flutter.git • Framework revision 6928314d50 (3 months ago), 2022-10-25 16:34:41 -0400 • Engine revision 3ad69d7be3 • Dart version 2.18.2 • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at ...../Library/Android/sdk • Platform android-33, build-tools 30.0.3 • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 14C18 • CocoaPods version 1.11.3

[✓] Android Studio (version 2021.3) • Android Studio at /Applications/Android Studio.app/Contents • 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)

[✓] VS Code (version 1.74.3) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.58.0

[✓] Connected device (1 available) • macOS (desktop) • macos • darwin-arm64 • macOS 13.1 22C65 darwin-arm (Rosetta)

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

• No issues found!

Description

I try to flutterfire configure my project but it seems that the Google-Services.json is too long. It is a Firebase Project with a lot of apps added. It succeeds when I use a firebase project with fewer apps.

This is the stack trace: Unhandled exception: FormatException: Unterminated string (at line 5, character 65458) ...
^

0 _ChunkedJsonParser.fail (dart:convert-patch/convert_patch.dart:1383:5)

1 _ChunkedJsonParser.close (dart:convert-patch/convert_patch.dart:494:9)

2 _parseJson (dart:convert-patch/convert_patch.dart:36:10)

3 JsonDecoder.convert (dart:convert/json.dart:612:36)

4 runFirebaseCommand (package:flutterfire_cli/src/firebase.dart:95:25)

#5 getAppSdkConfig (package:flutterfire_cli/src/firebase.dart:198:20) #6 FirebaseAndroidOptions.forFlutterApp (package:flutterfire_cli/src/firebase/firebase_android_options.dart:55:26) #7 ConfigCommand.run (package:flutterfire_cli/src/commands/config.dart:399:24) #8 CommandRunner.runCommand (package:args/command_runner.dart:209:13) #9 main (.../.pub-cache/hosted/pub.dartlang.org/flutterfire_cli-0.2.7/bin/flutterfire.dart:57:5) ### Steps to reproduce 1. flutterfire configure -p $FIREBASE_PROJECT --yes --platforms=ios,android 2. Wait until the android process begins. It finds the registered package name. But fetching or parsing of the JSON fails. (use a Firebase Project with a lot of apps, hence a large GoogleService.json) ### Expected behavior The configuration should succeed disregarding the length of the Google Services file. ### Screenshots _No response_ ### Additional context and comments _No response_
hwr12 commented 1 year ago

@leo-neon Hi. Have you tried with previous version of firebase or flutterfire_cli?

leo-neon commented 1 year ago

Hi @hwr12 , I tried out a few older versions now. All of them with the same error unfortunately. I am really wondering why it once worked before. As if the Google-Services.json has somehow become corrupt. But downloading it manually works und the file looks normal - like a valid JSON. The JSON Decoder under the hood fails.

hwr12 commented 1 year ago

@leo-neon I had same issues with you. I also haven't find any solution so what I did is to setup firebase in a native way. In android you could just place Google-Service.json in the android/app folder. You can set it in Ios as well in a native way.

ShineYang commented 1 year ago

This is indeed a serious bug, I don't know why it hasn't been fixed for so long.

russellwheatley commented 8 months ago

This was a problem with the Firebase CLI that has now been fixed in the current version. Please install the latest Firebase CLI via npm i -g firebase-tools. I would also encourage you to use the latest FlutterFire version:

dart pub global activate flutterfire_cli 0.3.0-dev.18 --overwrite