简体   繁体   中英

Flutterfire configure Unexpected character (at character 1) error

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?

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

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

**** 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 startedAdd 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;

     }

    

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

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

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 npm@9.2.0 as of now latest version of npm is 9.2.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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM