flutterfire_cli
flutterfire_cli copied to clipboard
FormatException error with flutterfire configure
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: https://github.com/invertase/flutterfire_cli/issues/27#issuecomment-1002965081
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 ?
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.
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/ed3b8f2c1f6ee4617742320856837b42f26cce05/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 mygoogle-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!
deleting android/app/google-services.json
worked for me
rm android/app/google-services.json
deleting
android/app/google-services.json
worked for merm android/app/google-services.json
@nilooy Thanks works for me too
deleting
android/app/google-services.json
worked for me, too!rm android/app/google-services.json
It works for me. thx!
rm android/app/google-services.json
This also worked for me
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
rm android/app/google-services.json
It saves my life
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
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.