Nana Kwame
Nana Kwame

Reputation: 1329

FirebaseCommandException: An error occured on the Firebase CLI when attempting to run a command

Flutterfire just added a CLI for us to use, but I'm having a problem with the flutterfire configure command. I keep getting this error:

i Found 0 Firebase projects. Selecting project liveasy-1. 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.

Even though I've installed the Firebase CLI and can run firebase --version without any issues. I installed the standalone binary and when that didn't work I installed it with npm as well. I can log in and see my projects list, but running flutterfire configure seems to be an issue. I can't also access any Firebase commands in Visual Studio Code.

Am I supposed to add something to the PATH in environmental variables? I've already added the cache/bin/ where flutterfire resides, but I don't know how to do the same for Firebase.

Upvotes: 83

Views: 144072

Answers (30)

AbirZayn
AbirZayn

Reputation: 150

Posting on 12 September 2024. When I have faced the exact same issue. Following instruction worked for me.Here is how I solved it.(android,ios) 1 -> package{your app} -> android -> app -> src -> main -> AndroidManifest.xml then here as you see no <manifest

xmlns:android="http://schemas.android.com/apk/res/android"
   "-------no package name----"
>

add the package name manually .Where to get it? android -> app -> build.gradle

android {
    namespace = "com.example.{your-app-name}"
    compileSdk = flutter.compileSdkVersion
    ndkVersion = flutter.ndkVersion

add this package name. Then come to the terminal re-run everysteps

  1. flutter pub add firebase_core
  2. dart pub global activate flutterfire_cli
  3. flutterfire configure.
  4. add the project now

I hope this solution helps you. Happy Coding

Upvotes: 1

Shreyas Papinwar
Shreyas Papinwar

Reputation: 63

I encountered the same issue, and after trying the suggested solutions (which didn’t work for me as my Firebase session was fine), I found that there might be two potential problems causing this error:

  1. Firebase session issue:
    If your session is expired or corrupted, try logging out and logging back in by running:

    firebase logout
    firebase login
    
  2. Node.js version: Sometimes the problem may be related to the version of Node.js you're using. For instance, my environment defaulted to Node 16, which caused issues. I had to switch to Node 18 using nvm.:

nvm use 18

Make sure you're using the correct version of Node.js that's compatible with Firebase.

Upvotes: 0

Harith Bashar
Harith Bashar

Reputation: 438

ALL THE ABOVE STEPS DID NOT WORK? look: I have this kind of problem when trying to register my app to firebase many times:

FirebaseCommandException: An error occured on the Firebase CLI when attempting to run a command.
COMMAND: firebase apps:create android ########(android) --package-name=############# --json --project=############ 
ERROR: Failed to create Android app for project ##############. See firebase-debug.log for more info.

let me tell you how this happen to me, I tried to delete my current project (android studio project NOT FIREBASE PROJECT) and create a newer one so the errors gone, but still doesn't work, I go to firebase and try to delete connected projects from their too so I can connect the new project on the same firebase project but it wouldn't work too. I realize that when You delete a connected project from firebase you should remove it from pending deletion too, because if you delete the connected projects twice or more in less than one month they will be still their and affect the new project connections. so to delete the pending deleted connected projects from firebase do the following:

1 .go to the firebase project on their website FIREBASE CONSOLE

  1. click the settings icon next to project view top left the screen and select project settings
  2. scroll down and you will see the pending connected projects, click on the 3 dots next to each one and delete them all.
  3. back to your project and try to reconnect it to the firebase.

thank me later, I'm really tired of this problem :).

Upvotes: 6

suffian ali
suffian ali

Reputation: 31

Make sure that the firebase project don't have the any app integrated with the same package name. I faced same issue.When i checked the firebase project setting where i delete the app but the app is not permanently deleted. That's why issue come. By this way, i have solved this issue.

Upvotes: 3

Mohamed Adan
Mohamed Adan

Reputation: 31

Run Firebase Init:

Initialize Firebase in your project by running:

firebase init

Upvotes: 2

Maruf Hassan
Maruf Hassan

Reputation: 1248

I was facing the same issue and nothing was working. I was trying to create a new project from the cli but it was always failing.

Solution: Make a project manually in Firebase Console instead. Then run the command flutterfire configure and you will be able to see the project. Select it and go through the process to complete the setup.

Upvotes: 1

Najmul.myself
Najmul.myself

Reputation: 23

Whoever is facing this issue in 2024 using a Mac, don't use git bash from VSCode, open the project from zsh. and run flutterfire configure.

Upvotes: 0

Roman
Roman

Reputation: 21

For Linux: I tried firebase logout firebase login, but without result Re-creating the project in Firebase helped me

Upvotes: 2

MinhTris
MinhTris

Reputation: 85

This is some of solutions I have tried

  • Try login/logout
  • Try to create project manual way in firebase website
  • Try with different project id

FYI: None of that one does the job

Upvotes: 1

Tiolu Akin
Tiolu Akin

Reputation: 21

For Windows: run 1.npm -g install firebase-tools 2.dart pub global activate flutterfire_cli 3.flutterfire configure

If the error is still there then restart your computer and run no.1 again. npm -g install firebase-tools

Upvotes: 2

Juggan
Juggan

Reputation: 1

delete C:\Users\USERNAME.cache\firebase

Run firebase-win-exe

Authentication process will start you press Y

Allow Firebase to collect CLI and Emulator Suite usage and error reporting information? Y

Copy a google link and paste it into browser and Log into your google account to allow access to firebase

Success! Logged in as [email protected]

enter image description here

Upvotes: -2

Muhammad Adil Mehmood
Muhammad Adil Mehmood

Reputation: 51

In FLUTTER [March 2024].

I added Firebase with the command 'flutterfire configure --project=PROJECT`, Then I scheduled the Android app in Firebase to delete which was preventing me from rerunning this command till I restored the app, and the command worked smoothly.

You can check your deletion scheduled apps under: Firebase console > Project settings > Your apps > pending deletion apps (LEFT PANE) click the app whose package you want to use and restore.

Upvotes: 2

Furkan Koseoglu
Furkan Koseoglu

Reputation: 129

Firebase CLI v13.3.0 is incompatible with Node.js v16.20.0 Please upgrade Node.js to version >=18.0.0 || >=20.0.0

In my case I just had to use higher node.js version.

nvm use 18

was solved the issue for me.

Upvotes: 1

abdallah tolba
abdallah tolba

Reputation: 11

It's JDK Path Problem you need to add Java JDK do the following seps:

1-Add JDK path to your user variables as example C:\Program Files\Java\jdk-16.0.2\bin. 2-then restart your terminal and try again flutterfire configur command. it work with me.

Upvotes: 0

mohamedaminehnioua
mohamedaminehnioua

Reputation: 84

For me I just added firebase_core plugin to pubspec.yaml, run flutter clean and flutter pub get, and rerun the flutterfire configure ... command and it worked.

Upvotes: 1

Aman Shaikh
Aman Shaikh

Reputation: 37

In order to resolve this issue you need to make sure that first download Firebase CLI binary for Windows (not standalone cli).

enter image description here

enter image description here

Now copy that firebase-tools-instant-win file into your project folder. And rename it to firebase.

Now open that firebase-tools-instant-win in downloads folder and be ready to type command.

  1. cd <path_of_your_project>
  2. firebase login
  3. dart pub global activate flutterfire_cli
  4. flutterfire configure

The reason that you were getting error because your firebase-tools-instant-win in downloads folder were unable to find cli named "firebase" so we are putting it by copying it from downloads folder.

Upvotes: 2

ibrahim alnagar
ibrahim alnagar

Reputation: 39

i had your same problem but when i run this command

npm install -g firebase-tools

in cmd the problem solved but note to run it in cmd not CLI , when you run it in ClI you will get warns and errors

Upvotes: 0

Abhishek Mishra
Abhishek Mishra

Reputation: 11

What worked for me was to enable scripts to run by setting the PowerShell execution policy as this was preventing me from running scripts.

Open PowerShell as an administrator Run the command: Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

Upvotes: 1

user22406266
user22406266

Reputation: 31

I had exactly same issue

The solution that worked for me:

  1. copy 'firebase-tools-instant-win.exe'. paste into your flutter project file, rename to 'firebase'.
  2. run 'flutterfire configure' on the command line (others had error).

Hope this helps

Upvotes: 3

Konstantin Kozirev
Konstantin Kozirev

Reputation: 1272

The only thing that helped me on Windows was just to use Android Studio's built-in terminal.

PowerShell and the Firebase EXE file both throw different errors and wouldn't work.

I also used all the solutions mentioned here and there without any luck.

Upvotes: 1

Quamar Hafid
Quamar Hafid

Reputation: 31

I tried to use the binary file from the official CLI website which is firebase-tool-instant-win.exe and naming it firebase.exe.

And then putting it in the Flutter project file that I am working on. It seems to do the trick.

Upvotes: 3

Sai Ratnakar
Sai Ratnakar

Reputation: 57

Make sure that you are using the same Gmail account, signed in Firebase CLI and Firebase console.

Then Relogin into the Firebase CLI

  1. Firebase logout

  2. Firebase login

Upvotes: 2

Unais IB
Unais IB

Reputation: 89

For me, it works only in the command prompt (not PowerShell or the Node.js runtime): Microsoft Windows

Upvotes: 0

Fuaad
Fuaad

Reputation: 89

It's fixed with me just by running the command:

"firebase login --reauth"

If your (Firebase debug log) contains a 401 error, then it just needs to be reauthorized.

To make sure that the this is the problem, run:

firebase projects:list and it will give you an error! then the solution is to reauthorize by the command above.

See: How do I solve: Error: Failed to list Firebase projects. See firebase-debug.log for more info

Upvotes: 8

A Tariq
A Tariq

Reputation: 81

I had the same problem.

In my case, it was the Node.js version. Try to do: firebase --version and if you have this message:

Firebase CLI v11.17.0 is incompatible with Node.js v12.14.0 Please upgrade Node.js to version ^14.18.0 || >=16.4.0

Just upgrade your Node.js version.

Upvotes: 0

Vinuka Vinnath
Vinuka Vinnath

Reputation: 81

The binary file didn't work for me either. But I found another way that worked for me.

  1. Go to the project's root.
  2. Open the Command prompt.
  3. Run npm install -g firebase-tools. (Make sure Node.js is installed)
  4. There may be a couple of WARN deprecations, but never mind.
  5. Then run flutterfire configure
  6. You will be asked to select the project and the mobile versions you are willing to build.
  7. Then make sure that a file was generated in 'lib\firebase_options.dart'

See the link for the image

Upvotes: 0

Hussein Babalola
Hussein Babalola

Reputation: 1

For a Mac, run flutterfire configure as a superuser, hence run sudo flutterfire configure in the terminal without quotes.

Upvotes: 0

Swaraj Singh
Swaraj Singh

Reputation: 101

The Problem:

Flutter Cli needs two CLI supports (FlutterFire and Firebase), but here only FlutterFire is installed and added to your environment configuration. Firebase also needs Firebase cli.

The Solution:

The solution is to add C:\Users<username>\AppData\Roaming\npm. This path in your environment configuration, and then restart your cmd, PowerShell, or Visual Studio Code.

By this, you will let your system know that here is an executable file, which should run globally on your machine.

Upvotes: 0

Quwaysim
Quwaysim

Reputation: 407

In case you run into another problem, especially this 👇

Unhandled exception:
FormatException: Unexpected character (at character 1)...

After Ventosus' answer, check this GitHub issue out. It helped me solve this issue.

Upvotes: 1

Kay Garr
Kay Garr

Reputation: 81

Download the standalone binary for the CLI for Windows. It will download an executable, firebase-tools-instant-win.exe.

Copy it into your preferred location

The important part is to enter the path where the executable resides in the Environment variables:

Environment variables → System variables → Path → New → Enter the path

Launch the file and enter the necessary commands.

firebase login

dart pub global activate flutterfire_cli

cd [your project directory]
flutterfire configure

Upvotes: 8

Related Questions