Flutterfire configure Unexpected character (at character 1) error
Asked Answered
H

14

10

I am developing a project with flutter and i want to add crashlytics to my project. Everything else works but flutterfire configure is giving me json error. I look every where for all possible answers but still not solving the issue.

npm commands

- firebase login
- npm install -g firebase-tools
- dart pub global activate flutterfire_cli
- flutterfire configure

all these commands is also works in android studio terminal. but flutterfire gives json error. I already added the android dependencies for firebase.

error log

⠏ 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:95:25)
<asynchronous suspension>
#6      getProjects (package:flutterfire_cli/src/firebase.dart:114:20)
<asynchronous suspension>
#7      ConfigCommand._selectFirebaseProject (package:flutterfire_cli/src/commands/config.dart:278:24)
<asynchronous suspension>
#8      ConfigCommand.run (package:flutterfire_cli/src/commands/config.dart:368:37)
<asynchronous suspension>
#9      CommandRunner.runCommand (package:args/command_runner.dart:209:13)
<asynchronous suspension>
#10     main (file:///C:/Users/USER/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutterfire_cli-0.2.4/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:95:25)
<asynchronous suspension>
#6      getProjects (package:flutterfire_cli/src/firebase.dart:114:20)
<asynchronous suspension>
#7      ConfigCommand._selectFirebaseProject (package:flutterfire_cli/src/commands/config.dart:278:24)
<asynchronous suspension>
#8      ConfigCommand.run (package:flutterfire_cli/src/commands/config.dart:368:37)
<asynchronous suspension>
#9      CommandRunner.runCommand (package:args/command_runner.dart:209:13)
<asynchronous suspension>
#10     main (file:///C:/Users/USER/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutterfire_cli-0.2.4/bin/flutterfire.dart:57:5)
<asynchronous suspension>

Would you please help me to solve this issue?

Hellraiser answered 25/7, 2022 at 15:56 Comment(15)
Post the code that is failingPortcullis
@JacobMiller, thanks for being fast. actually, it is firebase problem. I couldn't able to add my project to firebase in flutter. android and ios is already added. but flutter is giving me problem on flutterfire configureHellraiser
if android and iOS are added, then what are you trying to configure?Portcullis
If this is a Flutter project, why are you using npm?Portcullis
@JacobMiller What is rpm?Hellraiser
Stupid autocorrect, npm. I edited my comment with the correct spelling.Portcullis
Firebase needs to add configuration of flutterfire. And it needs npm. I tried it. and failed. I looked the web for possible solutions. But none of them is solved my issue. Lots of people struggled in the same place.Hellraiser
Can you comment here with the docs where it mentions npm? I looked and couldn't find it, they recently completely changed how Flutter and Firebase work together, that can be causing some communication problems.Portcullis
Yeah unfortunately. It is in here medium.com/flutter/…Hellraiser
That article is too old (no longer accurate) and not official docs.Portcullis
Sorry, this was the new one firebase.google.com/docs/flutter/setup?platform=androidHellraiser
I don't see where npm is mentionedPortcullis
In step one. There is Firebase cli if you aren't installed one. When you click the link,Hellraiser
Do you have node.js installed? What OS are you running?Portcullis
Yeap i am. I am using Windows 10, and i install npm, firebase cli.Hellraiser
S
3

For those of us on windows, do not forget to check if you are running an old version which you may have configured the PATH to point to. This seemed to be the problem in my case. I resolved by removing the old windows binary, then did a fresh install using npm (a fresh/updated windows install may work too). :

  • npm install -g firebase-tools

followed by:

  • firebase logout
  • firebase login then:
  • flutterfire configure
Sanjiv answered 10/11, 2022 at 7:9 Comment(2)
resolved my issue, using google_sign-in & firebase_auth, when logging in w/ google provider I kept getting "api-key-expired.-please-renew-the-api-key.". (optional?) update npm firebase-tools then running the above commands fixes the issue.Sonatina
Great, now I have to download node.js and have that bloating around: just fantasticEvitaevitable
H
2

**** update **** i resolve error by this step :

1 - re connect to network

2 - run dart pub global activate flutterfire_cli

3- run flutterfire configure

see Docs help you to get started Add Firebase To Flutter App

hope this help you

same error here i used firebase in another project but in this project it give me this

        Unhandled exception:

    FormatException: Unexpected character (at line 5, character 1)

    {

    ^

    

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

    #1      _ChunkedJsonParser.parse (dart:convert-patch/convert_patch.dart:848:48)

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

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

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

    <asynchronous suspension>

    #5      getApps (package:flutterfire_cli/src/firebase.dart:162:20)

    <asynchronous suspension>

    #6      findOrCreateFirebaseApp (package:flutterfire_cli/src/firebase.dart:257:34)

    <asynchronous suspension>

    #7      FirebaseAndroidOptions.forFlutterApp (package:flutterfire_cli/src/firebase/firebase_android_options.dart:47:25)

    <asynchronous suspension>

    #8      ConfigCommand.run (package:flutterfire_cli/src/commands/config.dart:377:24)

    <asynchronous suspension>

    #9      CommandRunner.runCommand (package:args/command_runner.dart:209:13)

    <asynchronous suspension>

    #10     main (file:///home/abdalazeez/.pub-cache/hosted/pub.dartlang.org/flutterfire_cli-0.2.4/bin/flutterfire.dart:57:5)

    <asynchronous suspension>

and this content file

         try {

       final flutterApp = await FlutterApp.load(Directory.current);

       await FlutterFireCommandRunner(flutterApp).run(arguments);  <=====the error happen here

     } on FlutterFireException catch (err) {

       if (utils.activeSpinnerState != null) {

         try {

           utils.activeSpinnerState!.done();

         } catch (_) {}

       }

       stderr.writeln(err.toString());

       exitCode = 1;

     } catch (err) {

       exitCode = 1;

       rethrow;

     }

    
Haven answered 29/8, 2022 at 12:1 Comment(1)
thank you. I solve it by using mac and with standalone binary :) I don't know why it is a big problem on windows.Hellraiser
A
2

following steps helped me:

  • update firebase cli

    curl -sL firebase.tools | upgrade=true bash

  • call

    firebase login --reauth

reference: https://github.com/invertase/flutterfire_cli/issues/27

Anticlockwise answered 23/9, 2022 at 9:56 Comment(1)
Thanks, i solve the issue using mac computer :)Hellraiser
A
2

I have faced the same issue. I tried the standalone binary version of Firebase CLI. I tried several ways to solve this issue such as,

  • Changing the name of "firebase-tools-instance.exe" to "firebase.exe"
  • Placing the firebase.exe in the root folder of my Flutter project

But they never worked for me.

Then I used npm to install Firebase CLI.

These are the steps I followed.

  1. I updated NodeJs to the latest version.

  2. I typed the following to install Firebase CLI.

    npm install -g firebase-tools
    
  3. Typed firebase login in the command prompt to check if it was successfully installed.

  4. Used dart pub global activate flutterfire_cli command to activate Flutterfire CLI.

  5. Went to the project root folder.

  6. Typed flutterfire configure to register apps in the project.

Successfully added a lib/firebase_options.dart configuration file to my Flutter project.

Asshur answered 18/6, 2023 at 6:15 Comment(0)
P
0

Try installing the Firebase CLI using the standalone binary instead of NPM on Windows, or the install script on Mac.

Portcullis answered 25/7, 2022 at 18:54 Comment(4)
I did that also =(Hellraiser
Was it still an NPM problem?Portcullis
i don't think it is npm. because npm install is working. but, configure command is giving wrong json parse. Is it about package name? we use multiple package namesHellraiser
I'm not sure, I don't think I can help any further.Portcullis
B
0

downloading and installing the node.js setup does the trick for me, after installation, search for the node.js terminal , then run 'firebase login', after login successfully, then run 'dart pub global activate flutterfire_cli', after succesfully getting the flutterfire cli, then navigate to the folder where the flutter app you created is using the cd(change directory) after navigating to the directory, then run 'flutterfire configure' this would create a firebase project in your flutter app project. finish

Bernete answered 14/11, 2022 at 19:10 Comment(0)
S
0

install latest version of npm and then run command of flutter fire. example: from any directory run: npm install -g npm@latest version => npm install -g [email protected] as of now latest version of npm is 9.2.0

Stupefacient answered 6/1, 2023 at 17:6 Comment(0)
S
0
  • Deleting the C:\Users\USERNAME.cache\firebase folder
  • Then re-running flutterfire configure worked for me after first trying the standalone binary and then nvm.
Singlefoot answered 8/1, 2023 at 22:32 Comment(0)
D
0

for linux and mac update the npm package

Diverse answered 28/4, 2023 at 5:42 Comment(0)
S
0

I just got the same error and i fixed this issue with re authenticate the firebase account using firebase login --reauth and then re run this command again dart pub global activate flutterfire_cli.

Selfimmolation answered 18/2, 2024 at 12:50 Comment(0)
C
0

I removed lib/firebase_options.dart and ran flutterfire configure

Caseation answered 3/3, 2024 at 13:28 Comment(0)
I
0

I fixed it typing same command, plus adding --verbose at the end

flutterfire configure --verbose

Hope it works for anyone. Apparently is an error through language/characters mismatch configuration and verbose helps debugging.

Isosceles answered 4/3, 2024 at 19:2 Comment(0)
C
0

If you are on windows and using the standalone binary for firebase mentioned in firebase documentation, try to install firebase cli through npm instead:

npm install -g firebase-tools

Also you will need to give permission to PowerShell to run firebase command (otherwise you will not be able to run firebase from PowerShell):

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

Then run

firebase login

And finally

dart pub global activate flutterfire_cli
Chiaki answered 10/3, 2024 at 15:14 Comment(0)
O
0
  1. Check in which Platform case u get this error.
  2. in my case was android
  3. I removed the file lib/firebase_opotions.dart and android/app/google-services.json
  4. run flutterfire configure again

that's work for me

Oosphere answered 15/3, 2024 at 8:14 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.