flutterfire_cli icon indicating copy to clipboard operation
flutterfire_cli copied to clipboard

FormatException error with flutterfire configure

Open Smartiiez opened this issue 2 years ago • 18 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>

Smartiiez avatar Jan 01 '22 10:01 Smartiiez

I had a similar issue (#33), but it was solved with the two commands here: https://github.com/invertase/flutterfire_cli/issues/27#issuecomment-1002965081

Maybe that will help.

chonghorizons avatar Jan 04 '22 21:01 chonghorizons

Thanks for the answer but I still get the error 😓

Smartiiez avatar Jan 10 '22 19:01 Smartiiez

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

mhussaines avatar Feb 01 '22 06:02 mhussaines

same issue

gaikwad2udit avatar Feb 06 '22 10:02 gaikwad2udit

Thanks for the answer but I still get the error 😓

did you find the solution ?

gaikwad2udit avatar Feb 06 '22 10:02 gaikwad2udit

Yes, I just updated the firebase_message version in pubspec.yaml file and it started working without any code change.

Mohammad Hussain Anwar Computer Programmer (iOS Developer) Excellent Solutions Tel: +966 11 4196560 Ext-135 Mob: +966-53-6256339 Email: @.*** Regards,

On 6 Feb 2022, at 1:40 PM, gaikwad2udit @.***> wrote:

Thanks for the answer but I still get the error 😓

did you find the solution ?

— Reply to this email directly, view it on GitHub https://github.com/invertase/flutterfire_cli/issues/30#issuecomment-1030805300, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVEO3XCIOYOAB6OTTDKSLATUZZF2XANCNFSM5LCKW3ZQ. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you commented.

mhussaines avatar Feb 06 '22 12:02 mhussaines

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

Nico04 avatar Feb 23 '22 15:02 Nico04

In my case installing from npm solved the issue.

npm install -g firebase-tools

tomlaws avatar Apr 16 '22 11:04 tomlaws

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

SpaceBug199 avatar Jun 12 '22 08:06 SpaceBug199

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)

bastaware avatar Aug 12 '22 21:08 bastaware

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

vincekruger avatar Sep 17 '22 11:09 vincekruger

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.

ArAmM7 avatar Sep 25 '22 18:09 ArAmM7

@Smartiiez - are you running in a windows environment?

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

russellwheatley avatar Sep 28 '22 09:09 russellwheatley

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

FDuhen avatar Sep 29 '22 06:09 FDuhen

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>

normidar avatar Oct 01 '22 15:10 normidar

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/ed3b8f2c1f6ee4617742320856837b42f26cce05/packages/flutterfire_cli/lib/src/firebase/firebase_android_gradle_plugins.dart#L67

normidar avatar Oct 01 '22 16:10 normidar

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 🥳🥳🥳

noodles avatar Oct 11 '22 01:10 noodles

sudo gem install xcodeproj fixed the problem entirely.

Thanks!

vincekruger avatar Oct 11 '22 07:10 vincekruger

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.

syeds-git avatar Dec 04 '22 05:12 syeds-git

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.

cosmopool avatar Jan 13 '23 11:01 cosmopool

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

fullflash avatar Jan 27 '23 21:01 fullflash

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!

nsweatlas avatar Feb 08 '23 17:02 nsweatlas

deleting android/app/google-services.json worked for me

rm android/app/google-services.json

nilooy avatar Mar 10 '23 15:03 nilooy

deleting android/app/google-services.json worked for me

rm android/app/google-services.json

@nilooy Thanks works for me too

erlangparasu avatar May 09 '23 05:05 erlangparasu

deleting android/app/google-services.json worked for me, too!

rm android/app/google-services.json

It works for me. thx!

niceman114 avatar May 20 '23 08:05 niceman114

rm android/app/google-services.json

This also worked for me

VinGitonga avatar May 27 '23 08:05 VinGitonga

I did following steps and it worked for me.

  • Run flutter doctor, and resolved issues.
  • Installed rebnv
  • Installed Cocoapods (Learned from ChatGPT the steps to install Cocoapods through rebnv)
  • Installed xcodeproj sudo gem install xcodeproj
  • Restart IDE
  • logout and login from firebase.
  • Deleted google-service.json under app android>app directory.
  • Lastly configure Firebase Project flutterfire configure

asad-mansoor-dev avatar Jun 01 '23 13:06 asad-mansoor-dev

rm android/app/google-services.json

It saves my life

pnhoanglong avatar Aug 30 '23 08:08 pnhoanglong

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.

rm android/app/google-services.json

works for me , thank you

WhiteRiverBay avatar Aug 30 '23 17:08 WhiteRiverBay

Hey folks, we have cut the latest dev release which you can install like so:

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

If you also install the latest Firebase CLI npm i -g firebase-tools, they have a fix for malformed JSON responses (what FlutterFire CLI uses under the hood) which they have just released 👍. This ought to fix @Smartiiez's issue.

russellwheatley avatar Sep 14 '23 08:09 russellwheatley