Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flutterfire configure, FormatException: Unexpected character (at character 1) #55

Closed
syahmewmew opened this issue Apr 12, 2022 · 30 comments · Fixed by #224
Closed

flutterfire configure, FormatException: Unexpected character (at character 1) #55

syahmewmew opened this issue Apr 12, 2022 · 30 comments · Fixed by #224
Labels
bug Something isn't working

Comments

@syahmewmew
Copy link

syahmewmew commented Apr 12, 2022

PS C:\Users\HP\Documents\myapp\cas_testing_1\flutter_application_1> flutterfire configure        
⠹ 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:96:25)
<asynchronous suspension>
#6      getProjects (package:flutterfire_cli/src/firebase.dart:115:7)
<asynchronous suspension>
#7      ConfigCommand._selectFirebaseProject (package:flutterfire_cli/src/commands/config.dart:184:24)
<asynchronous suspension>
#8      ConfigCommand.run (package:flutterfire_cli/src/commands/config.dart:253:37)
<asynchronous suspension>
#9      CommandRunner.runCommand (package:args/command_runner.dart:209:13)
<asynchronous suspension>
#10     main (file:///C:/Users/HP/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutterfire_cli-0.1.3/bin/flutterfire.dart:57:5)
<asynchronous suspension>
⠼ 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:96:25)
<asynchronous suspension>
#6      getProjects (package:flutterfire_cli/src/firebase.dart:115:7)
<asynchronous suspension>
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:96:25)
<asynchronous suspension>
#6      getProjects (package:flutterfire_cli/src/firebase.dart:115:7)
<asynchronous suspension>
#7      ConfigCommand._selectFirebaseProject (package:flutterfire_cli/src/commands/config.dart:184:24)
<asynchronous suspension>
<asynchronous suspension>
#9      CommandRunner.runCommand (package:args/command_runner.dart:209:13)
<asynchronous suspension>
7:5)
<asynchronous suspension>
@Salakar Salakar added the bug Something isn't working label Apr 13, 2022
@k00na
Copy link

k00na commented Apr 16, 2022

Same here!

Here's my Flutter doctor -v output

[✓] Flutter (Channel stable, 2.10.4, on macOS 11.4 20F71 darwin-x64, locale en-GB)
• Flutter version 2.10.4 at /Users/igor/dev/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision c860cba910 (3 weeks ago), 2022-03-25 00:23:12 -0500
• Engine revision 57d3bac3dd
• Dart version 2.16.2
• DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
• Android SDK at /Users/igor/Library/Android/sdk
• Platform android-31, build-tools 32.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
• All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 12.5.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
! Flutter recommends a minimum Xcode version of 13.
Download the latest version or update via the Mac App Store.
• CocoaPods version 1.10.1

[✓] Android Studio (version 4.0)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 51.0.1
• Dart plugin version 193.7547
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] Android Studio (version 4.0)
• Android Studio at /Applications/Android Studio 2.app/Contents
• Flutter plugin version 51.0.1
• Dart plugin version 193.7547
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

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

[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-x64 • macOS 11.4 20F71 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 100.0.4896.88

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

@yanivshaked
Copy link

Same issue here, is there any workaround available?

@k00na
Copy link

k00na commented Apr 24, 2022

What helped me in the end was to logout of firebase and login again, you can do that with firebase login --reauth

@yanivshaked
Copy link

Thanks

@duartevg
Copy link

duartevg commented May 6, 2022

Hi, using the firebase login --reauth didn't solve it for me, did you manage to find a workaround in the meantime?

@BenVercammen
Copy link

I have the same issue using Firebase CLI (on Windows). However, when I do this from a regular terminal (actually, my IDEA's terminal, but I guess a command prompt would be the same), it just worked...

firebase tools --version showed me I'm working with 9.2.2.
So I tried to update my version using npm install -g firebase-tools but eventually got an error
(node:10388) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_VALUE]: The argument 'file' cannot be empty. Received '' and decided to let it rest for now.

Hope this is helpful for someone else...

@danPyk
Copy link

danPyk commented May 9, 2022

I have same isssue when I'm trying to use flutterfire configure in Android Studio terminal.
Interesting thing: when I'm trying the same in standalone cmd prompt I'm getting:

i Found 0 Firebase projects. Selecting project addicts-guardian-7cac9.
FirebaseCommandException: An error occured on the Firebase CLI when attempting to run a command.
COMMAND: firebase --version
ERROR: The FlutterFire CLI currently requires the official Firebase CLI to also be installed, see https://firebase.google.com/docs/cli#install_the_firebase_cli for how to install it.

But I've got installed Firebase CLI, via WSL.
I've tried to reinstall npm+node+firebase-tools but without effect. I've even created a new firebase project, to try deal with this issue, I'm able to work with cli, deploy functions etc., but still can't get firebase_options file.

Here's flutter doctor:

"Flutter doctor -v output
[√] Flutter (Channel stable, 2.10.5, on Microsoft Windows [Version 10.0.19044.1645], locale pl-PL)
• Flutter version 2.10.5 at C:\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 5464c5bac7 (3 weeks ago), 2022-04-18 09:55:37 -0700
• Engine revision 57d3bac3dd
• Dart version 2.16.2
• DevTools version 2.9.2

[√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
• Android SDK at C:\Users\komputerz\AppData\Local\Android\sdk
• Platform android-32, build-tools 32.1.0-rc1
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
• All Android licenses accepted.

[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.10.2)
• Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
• Visual Studio Community 2019 version 16.10.31410.357
• Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2021.2)
• Android Studio at C:\Program Files\Android\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.12+7-b1504.28-7817840)

[√] Connected device (4 available)
• sdk gphone x86 (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19044.1645]
• Chrome (web) • chrome • web-javascript • Google Chrome 101.0.4951.54
• Edge (web) • edge • web-javascript • Microsoft Edge 101.0.1210.32

[√] HTTP Host Availability
• All required HTTP hosts are available"

@robertflesch
Copy link

i Found 0 Firebase projects. Selecting project addicts-guardian-7cac9.
FirebaseCommandException: An error occured on the Firebase CLI when attempting to run a command.
COMMAND: firebase --version
ERROR: The FlutterFire CLI currently requires the official Firebase CLI to also be installed, see

Way to solve this one is rename the firebase_windows_xxx.exe to firebase.exe

@danPyk
Copy link

danPyk commented May 19, 2022

@robertflesch Thank's Robert, but I've already tried this, not helping. Today I've unistall firbease-tools, node.js and wsl to try install this time throught nvm, but I'm still getting error after flutterfire configure command:

flutterfire configure
i Found 0 Firebase projects. Selecting project addicts-guardian-7cac9.
FirebaseCommandException: An error occured on the Firebase CLI when attempting to run a command.
COMMAND: firebase --version
ERROR: The FlutterFire CLI currently requires the official Firebase CLI to also be installed, see https://firebase.google.com/docs/cli#install_the_firebase_cli for how to install it.

firebase --version
10.8.0

@robertflesch
Copy link

robertflesch commented May 19, 2022 via email

@Patler
Copy link

Patler commented May 28, 2022

I've had this issue for a while, just solved it for me.

The key was to not run "flutterfire configure" in the VSCode Terminal, but in the flutterfireCLI Terminal.

Normally when executing "flutterfire configure" in the flutterfireCLI it tells you "FlutterAppRequiredException: The current directory does not appear to be a Flutter application project.", that is because you have to navigate to the correct directory first.

In the FlutterfireCLI Terminal, use "cd" to find your current directory. Then navigate to the directory of your Flutter Project ( The same you should be in currently, in VSCode. From there type "flutterfire configure".

This workaround worked for me, hope it helps.

@nuilewis
Copy link

nuilewis commented Jun 20, 2022

I've had this issue for a while, just solved it for me.

The key was to not run "flutterfire configure" in the VSCode Terminal, but in the flutterfireCLI Terminal.

Normally when executing "flutterfire configure" in the flutterfireCLI it tells you "FlutterAppRequiredException: The current directory does not appear to be a Flutter application project.", that is because you have to navigate to the correct directory first.

In the FlutterfireCLI Terminal, use "cd" to find your current directory. Then navigate to the directory of your Flutter Project ( The same you should be in currently, in VSCode. From there type "flutterfire configure".

This workaround worked for me, hope it helps.

I tried this but it did not work for me, because the flutterfire was not recognized in my Firebase CLI even though I included the path to my flutterfire CLI in my environment variables. Don't know why it behaves like this.

After going through the flutterfire.bat file in my C:\Users\%USER_NAME%\AppData\Local\Pub\Cache\bin directory, I realized the flutterfire command actually runs this dart command dart pub global run flutterfire_cli:flutterfire. So I copied this and appended the configure command like so dart pub global run flutterfire_cli:flutterfire configure and ran this in my Firebase CLI and it worked.

Hope this helps somebody.

@TBK12
Copy link

TBK12 commented Nov 16, 2022

So just come across this issue myself, and wanted to clarify a few things written previously (or propose yet another way that seems to have worked for me). Personally, I think the instructions given for the firebase CLI (+ Flutter integration) by the official documentation could be much clearer.

[This is using the standalone windows firebase-tools-instant-win.exe]

  1. Download firebase-tools-instant-win.exe from FirebaseCLI like normal
  2. Move firebase-tools-instant-win.exe to the root of your Flutter app
  3. [IMPORTANT] Duplicate this .exe and rename one copy firebase.exe
  4. Run dart pub global activate flutterfire_cli from anywhere and add C:\Users\%USER_NAME%\AppData\Local\Pub\Cache\bin to your User Path variable
  5. Run firebase-tools-instant-win.exe (from the root project folder) and login if not done already
  6. Enter flutterfire configure into the FirebaseCLI

It seems that flutterfire needs to be run inside the FlutterCLI rather than Windows terminal, and is expecting to find a firebase.exe file. Whereas for FirebaseCLI to run properly, it self-references a firebase-tools-instant-win.exe file, hence the duplicate files. At least for me, simply renaming the FirebaseCLI executable caused it to break.

Hopefully this helps someone out there.

@ssdev98
Copy link

ssdev98 commented Nov 16, 2022

same here

@yaakoubDj
Copy link

i solved it by :
use olded version of firebase-core (firebase_core: ^1.10.6) and everything will
worked

@pepeptium
Copy link

6. flutterfire configure

Thank you. You saved my day

@Rosivaldoferro
Copy link

Consegui usando o PowerShell ao inves de outros terminais

@supa-modo
Copy link

So just come across this issue myself, and wanted to clarify a few things written previously (or propose yet another way that seems to have worked for me). Personally, I think the instructions given for the firebase CLI (+ Flutter integration) by the official documentation could be much clearer.

[This is using the standalone windows firebase-tools-instant-win.exe]

  1. Download firebase-tools-instant-win.exe from FirebaseCLI like normal
  2. Move firebase-tools-instant-win.exe to the root of your Flutter app
  3. [IMPORTANT] Duplicate this .exe and rename one copy firebase.exe
  4. Run dart pub global activate flutterfire_cli from anywhere and add C:\Users\%USER_NAME%\AppData\Local\Pub\Cache\bin to your User Path variable
  5. Run firebase-tools-instant-win.exe (from the root project folder) and login if not done already
  6. Enter flutterfire configure into the FirebaseCLI

It seems that flutterfire needs to be run inside the FlutterCLI rather than Windows terminal, and is expecting to find a firebase.exe file. Whereas for FirebaseCLI to run properly, it self-references a firebase-tools-instant-win.exe file, hence the duplicate files. At least for me, simply renaming the FirebaseCLI executable caused it to break.

Hopefully this helps someone out there.

Thanks man, I've struggled with this for more than a week now. Only your solution worked

@cybex-dev
Copy link

cybex-dev commented Feb 24, 2023

This solution might be helpful to some here. #27 (comment)

TL;DR

  • use latest firebase-tools
  • relog firebase cmd/terminal

@AnuragBishnoi
Copy link

AnuragBishnoi commented Apr 5, 2023

its been two days , none of these worked for me . i have tried installing with both CLI and npm method. if i run the "flutterfire configure" from the firebase.exe it gives me this error =
"i Found 0 Firebase projects.
FirebaseCommandException: An error occured on the Firebase CLI when attempting to run a command.
COMMAND: firebase --version
ERROR: The FlutterFire CLI currently requires the official Firebase CLI to also be installed, see https://firebase.google.com/docs/cli#install_the_firebase_cli for how to install it."

however "firebase projects:list " is working fine .

When i try with running the "flutterfire configure" from the terminal in the same folder instead of the firebase.exe , it gives me the same "unhandeled exception" error which the OP is facing.

i have added path of everything in the environment variables.
Also tried updating with the npm commands.
i also tried logging in and out , reauth.

Edit : (found a solution) the issue was , i was using the LTS version of node , so after updating it using NVM and reinstalling everything fixed the issue for me. 🙂.

@Suryanshomar7240
Copy link

So just come across this issue myself, and wanted to clarify a few things written previously (or propose yet another way that seems to have worked for me). Personally, I think the instructions given for the firebase CLI (+ Flutter integration) by the official documentation could be much clearer.

[This is using the standalone windows firebase-tools-instant-win.exe]

  1. Download firebase-tools-instant-win.exe from FirebaseCLI like normal
  2. Move firebase-tools-instant-win.exe to the root of your Flutter app
  3. [IMPORTANT] Duplicate this .exe and rename one copy firebase.exe
  4. Run dart pub global activate flutterfire_cli from anywhere and add C:\Users\%USER_NAME%\AppData\Local\Pub\Cache\bin to your User Path variable
  5. Run firebase-tools-instant-win.exe (from the root project folder) and login if not done already
  6. Enter flutterfire configure into the FirebaseCLI

It seems that flutterfire needs to be run inside the FlutterCLI rather than Windows terminal, and is expecting to find a firebase.exe file. Whereas for FirebaseCLI to run properly, it self-references a firebase-tools-instant-win.exe file, hence the duplicate files. At least for me, simply renaming the FirebaseCLI executable caused it to break.

Hopefully this helps someone out there.

Thanks for saving my day :D

@ismetatakli
Copy link

It was fixed when I downloaded nodejs from its own site and installed it again.

@MohammadJamal7
Copy link

So just come across this issue myself, and wanted to clarify a few things written previously (or propose yet another way that seems to have worked for me). Personally, I think the instructions given for the firebase CLI (+ Flutter integration) by the official documentation could be much clearer.

[This is using the standalone windows firebase-tools-instant-win.exe]

  1. Download firebase-tools-instant-win.exe from FirebaseCLI like normal
  2. Move firebase-tools-instant-win.exe to the root of your Flutter app
  3. [IMPORTANT] Duplicate this .exe and rename one copy firebase.exe
  4. Run dart pub global activate flutterfire_cli from anywhere and add C:\Users\%USER_NAME%\AppData\Local\Pub\Cache\bin to your User Path variable
  5. Run firebase-tools-instant-win.exe (from the root project folder) and login if not done already
  6. Enter flutterfire configure into the FirebaseCLI

It seems that flutterfire needs to be run inside the FlutterCLI rather than Windows terminal, and is expecting to find a firebase.exe file. Whereas for FirebaseCLI to run properly, it self-references a firebase-tools-instant-win.exe file, hence the duplicate files. At least for me, simply renaming the FirebaseCLI executable caused it to break.

Hopefully this helps someone out there.

You don't know how much time I spent trying to solve this problem! thanks a lot man.
For those with whom this did not work, make 2 copies of firebase-tools-instant-win.exe in the root of your project, change the name of one of them and run the other one(the original name) and continue the steps above.

@mehdigharibi
Copy link

I've had this issue for a while, just solved it for me.
The key was to not run "flutterfire configure" in the VSCode Terminal, but in the flutterfireCLI Terminal.
Normally when executing "flutterfire configure" in the flutterfireCLI it tells you "FlutterAppRequiredException: The current directory does not appear to be a Flutter application project.", that is because you have to navigate to the correct directory first.
In the FlutterfireCLI Terminal, use "cd" to find your current directory. Then navigate to the directory of your Flutter Project ( The same you should be in currently, in VSCode. From there type "flutterfire configure".
This workaround worked for me, hope it helps.

I tried this but it did not work for me, because the flutterfire was not recognized in my Firebase CLI even though I included the path to my flutterfire CLI in my environment variables. Don't know why it behaves like this.

After going through the flutterfire.bat file in my C:\Users\%USER_NAME%\AppData\Local\Pub\Cache\bin directory, I realized the flutterfire command actually runs this dart command dart pub global run flutterfire_cli:flutterfire. So I copied this and appended the configure command like so dart pub global run flutterfire_cli:flutterfire configure and ran this in my Firebase CLI and it worked.

Hope this helps somebody.

thank you you save my time afte 24hours research :D . your method is work fine for me.

@SandyCooper
Copy link

I have the same issue which is,

`$ dart pub global run flutterfire_cli:flutterfire configure
⠧ Fetching available Firebase projects...
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:610:36)
#4 runFirebaseCommand (package:flutterfire_cli/src/firebase.dart:95:25)

#5 getProjects (package:flutterfire_cli/src/firebase.dart:114:20)

#6 ConfigCommand._selectFirebaseProject (package:flutterfire_cli/src/commands/config.dart:300:24)

#7 ConfigCommand.run (package:flutterfire_cli/src/commands/config.dart:390:37)
#8 CommandRunner.runCommand (package:args/command_runner.dart:212:13)

#9 main (file:///C:/Users/Lenovo/AppData/Local/Pub/Cache/hosted/pub.dev/flutterfire_cli-0.2.7/bin/flutterfire.dart:57:5)
`

I have tried all the above solution none of them worked for me. I have been trying for more than 1 week nothing happens. Please Kindly rectify this issue. PLEASE!!!

@Eraytann
Copy link

Eraytann commented Dec 1, 2023

So just come across this issue myself, and wanted to clarify a few things written previously (or propose yet another way that seems to have worked for me). Personally, I think the instructions given for the firebase CLI (+ Flutter integration) by the official documentation could be much clearer.
[This is using the standalone windows firebase-tools-instant-win.exe]

  1. Download firebase-tools-instant-win.exe from FirebaseCLI like normal
  2. Move firebase-tools-instant-win.exe to the root of your Flutter app
  3. [IMPORTANT] Duplicate this .exe and rename one copy firebase.exe
  4. Run dart pub global activate flutterfire_cli from anywhere and add C:\Users\%USER_NAME%\AppData\Local\Pub\Cache\bin to your User Path variable
  5. Run firebase-tools-instant-win.exe (from the root project folder) and login if not done already
  6. Enter flutterfire configure into the FirebaseCLI

It seems that flutterfire needs to be run inside the FlutterCLI rather than Windows terminal, and is expecting to find a firebase.exe file. Whereas for FirebaseCLI to run properly, it self-references a firebase-tools-instant-win.exe file, hence the duplicate files. At least for me, simply renaming the FirebaseCLI executable caused it to break.
Hopefully this helps someone out there.

You don't know how much time I spent trying to solve this problem! thanks a lot man. For those with whom this did not work, make 2 copies of firebase-tools-instant-win.exe in the root of your project, change the name of one of them and run the other one(the original name) and continue the steps above.

Thank you so much for your help. I am really appreciate it!

@Sassha5
Copy link

Sassha5 commented Dec 24, 2023

  1. [IMPORTANT] Duplicate this .exe and rename one copy firebase.exe

It seems that flutterfire needs to be run inside the FlutterCLI rather than Windows terminal, and is expecting to find a firebase.exe file. Whereas for FirebaseCLI to run properly, it self-references a firebase-tools-instant-win.exe file, hence the duplicate files. At least for me, simply renaming the FirebaseCLI executable caused it to break.

Thank you! I tried everything else you can find in other tickets or StackOverflow but this was exactly the missing piece.

@jdiaz97
Copy link

jdiaz97 commented Feb 5, 2024

2024, same issue here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet