invertase/flutterfire_cli

FormatException error with flutterfire configure

Smartiiez opened this issue ยท 31 comments

Hi ๐Ÿ‘‹,

I got FormatException when I run the flutter configure command line :

Unhandled exception:
FormatException: Unexpected end of input (at character 1)

^

#0      _ChunkedJsonParser.fail (dart:convert-patch/convert_patch.dart:1405:5)
#1      _ChunkedJsonParser.close (dart:convert-patch/convert_patch.dart:523:7)
#2      _parseJson (dart:convert-patch/convert_patch.dart:41:10)
#3      JsonDecoder.convert (dart:convert/json.dart:506:36)
#4      runFirebaseCommand (package:flutterfire_cli/src/firebase.dart:95:25)
<asynchronous suspension>
#5      getProjects (package:flutterfire_cli/src/firebase.dart:114:7)
<asynchronous suspension>
#6      ConfigCommand._selectFirebaseProject (package:flutterfire_cli/src/commands/config.dart:159:24)
<asynchronous suspension>
#7      ConfigCommand.run (package:flutterfire_cli/src/commands/config.dart:227:37)
<asynchronous suspension>
#8      CommandRunner.runCommand (package:args/command_runner.dart:209:13)
<asynchronous suspension>
#9      main (file:///Users/home/.pub-cache/hosted/pub.dartlang.org/flutterfire_cli-0.1.1+2/bin/flutterfire.dart:34:5)
<asynchronous suspension>

I had a similar issue (#33), but it was solved with the two commands here: #27 (comment)

Maybe that will help.

Thanks for the answer but I still get the error ๐Ÿ˜“

Thanks for the answer but I still get the error too.

same issue

Thanks for the answer but I still get the error ๐Ÿ˜“

did you find the solution ?

Same issue here on Windows.
I installed the firebase CLI from the standalone version, moved to my project folder and rename it to firebase.exe
But when using flutterfire command it throws FormatException
I've tried few comments found on github, without any luck

In my case installing from npm solved the issue.

npm install -g firebase-tools

I had the same issue on macOS with npm installation of firebase-tools.
My problem was that npm installed firebase-tools version 8.0.2. and the current version was 11.0.1.

To check your version run firebase --version

I have solved this issue by running
curl -sL firebase.tools | upgrade=true bash

current

This helped me on Mac OSX. Though I needed to upgrade firebase.tools using npm. First I had to upgrade node, also using npm.

But when I ran flutterfire configure, I got a new error: i Found 0 Firebase projects.

This was solved by logging out and into Firebase (firebase logout, firebase login)

Urg. I'm getting this error all the time despite all the suggestions on many threads and comments. :(

For anyone wondering what works on windows, I used cmd as admin to run the flutterfire configure command and it worked. I am using the npm version of firebase cli.

@Smartiiez - are you running in a windows environment?

Also same question to everyone who is experiencing this problem, @here?

Updating this issue with a slightly different problem, but the root cause may be the same.
Environment : Mac M1 Monterey

firebase-tools version: 11.11.0
flutterfire version : 0.2.6
flutter version : tried with 3.0.1 and 3.3.2
dart version : 2.18.2

Stacktrace:

โ น Fetching available Firebase projects...                                                                                                                          
Unhandled exception:
FormatException: Unexpected end of input (at line 1981, character 9)
      },
        ^

#0      _ChunkedJsonParser.fail (dart:convert-patch/convert_patch.dart:1383:5)
#1      _ChunkedJsonParser.close (dart:convert-patch/convert_patch.dart:501:7)
#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)
<asynchronous suspension>
#5      getProjects (package:flutterfire_cli/src/firebase.dart:114:20)
<asynchronous suspension>
#6      ConfigCommand._selectFirebaseProject (package:flutterfire_cli/src/commands/config.dart:278:24)
<asynchronous suspension>
#7      ConfigCommand.run (package:flutterfire_cli/src/commands/config.dart:368:37)
<asynchronous suspension>
#8      CommandRunner.runCommand (package:args/command_runner.dart:209:13)
<asynchronous suspension>
#9      main (file:///Users/fduhen/.pub-cache/hosted/pub.dartlang.org/flutterfire_cli-0.2.6/bin/flutterfire.dart:57:5)
<asynchronous suspension>

The fixes I've tried so far without any success :

  • Reinstalling firebase-tools
  • Deactivating/reactivating flutterfire_cli and reconnecting
  • Updating Dart

I have the same issue here(using macOS M1):

I can not fix it after these :

  • flutter clean
  • install firebase-tools latest version
  • upgrade flutter & dart
  • upgrade packages about firebase
  • close vscode and reopen
Unhandled exception:
FormatException: Unexpected end of input (at character 1)

^

#0      _ChunkedJsonParser.fail (dart:convert-patch/convert_patch.dart:1383:5)
#1      _ChunkedJsonParser.close (dart:convert-patch/convert_patch.dart:501:7)
#2      _parseJson (dart:convert-patch/convert_patch.dart:36:10)
#3      JsonDecoder.convert (dart:convert/json.dart:612:36)
#4      FirebaseAndroidOptions.projectIdFromFileContents (package:flutterfire_cli/src/firebase/firebase_android_options.dart:29:29)
#5      FirebaseAndroidGradlePlugins.applyGoogleServicesPlugin (package:flutterfire_cli/src/firebase/firebase_android_gradle_plugins.dart:101:50)
<asynchronous suspension>
#6      FirebaseAndroidGradlePlugins.apply (package:flutterfire_cli/src/firebase/firebase_android_gradle_plugins.dart:240:5)
<asynchronous suspension>

I checked the flutterfire_cli code, I think the problem is my google-services.json file, I redownloaded it and fixed this error.

see:
https://github.com/invertase/flutterfire_cli/blob/main/packages/flutterfire_cli/lib/src/firebase/firebase_android_gradle_plugins.dart#L67

tl;dr: Fixed using sudo gem install xcodeproj after redownloading google-services.json ๐Ÿฅณ

===

I tried all of the steps listed here as well as those listed above.

I checked the flutterfire_cli code, I think the problem is my google-services.json file, I re-downloaded it and fixed this error.

Deleting and redownloading the google-services.json from the Project settings section of my project's Firebase console didn't work but it did throw a different unhandled exception:

Unhandled exception:
Exception: /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- xcodeproj (LoadError)
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from -e:1:in `<main>'

#0      ConfigCommand.run (package:flutterfire_cli/src/commands/config.dart:517:11)
<asynchronous suspension>
#1      CommandRunner.runCommand (package:args/command_runner.dart:209:13)
<asynchronous suspension>
#2      main (file:///Users/hallrichard/.pub-cache/hosted/pub.dartlang.org/flutterfire_cli-0.2.6/bin/flutterfire.dart:57:5)
<asynchronous suspension>

Running this command fixed the issue for me:

sudo gem install xcodeproj

I have tested flutterfire configure on new & existing Flutter projects & it works as expected ๐Ÿฅณ๐Ÿฅณ๐Ÿฅณ

sudo gem install xcodeproj fixed the problem entirely.

Thanks!

I checked the flutterfire_cli code, I think the problem is my google-services.json file, I redownloaded it and fixed this error.

see: https://github.com/invertase/flutterfire_cli/blob/main/packages/flutterfire_cli/lib/src/firebase/firebase_android_gradle_plugins.dart#L67

So this happened to me in Dec 2022 after I attempted to add firebase_auth: ^4.1.5. I had first installed and tested the following

firebase_core: ^2.3.0
firebase_analytics: ^10.0.6

and then proceeded on to add firebase_auth and then as instructed in the official docs ran the flutterfire configure. This resulted in the above error. I checked the google-services.json file and noticed that it was wiped out. So I downloaded it manually and resolved the issue.

For me, on a mac m1:

  • sudo gem install xcodeproj
  • curl -sL firebase.tools | upgrade=true bash
  • rm android/app/google-services.json

Solved the issue.

For me, on a mac m1:

  • sudo gem install xcodeproj
  • curl -sL firebase.tools | upgrade=true bash
  • rm android/app/google-services.json

Solved the issue.

also firebase login --reauth

For anyone wondering what works on windows, I used cmd as admin to run the flutterfire configure command and it worked. I am using the npm version of firebase cli.

This worked for me, thanks! I had issues running it in the Firebase CLI ๐Ÿ˜…

Just to document for myself (Windows 10), when running 'flutterfire configure', I had 'FirebaseCommandException' issue earlier.
Renaming a copy of 'firebase-tools-instant-win.exe' to 'firebase.exe' didn't work for me, neither did reauth, or logout-login again, turns out it was as simple as running 'npm get prefix' and adding that to Path in System variables. Then I ran into this same issue as parent thread, which is solved (for me) by simply running in command line instead ๐Ÿ˜… thanks again!