Ethical Aniruddha
Ethical Aniruddha

Reputation: 11

[flutterfire]: PathNotFoundException: Cannot open file 'android/build.gradle' when running flutterfire configure

Q) Is there an existing issue for this?

I have searched the existing issues.

Q) Which plugins are affected?

Other

Q) Which platforms are affected?

Android, iOS, macOS, Web, Windows

Description

When running the flutterfire configure command to set up Firebase for a Flutter project, the process fails with a PathNotFoundException error. The error indicates that the build.gradle file in the [android] directory cannot be found. This issue occurs even though the Firebase configuration for Android, iOS, macOS, web, and Windows platforms is successfully registered.

Reproducing the issue

flutter create example
cd example
dart pub global activate flutterfire_cli
flutterfire configure

error

Firebase Core version 3.9.0

Flutter Version 3.28.0-2.0.pre.38577 • channel master

Tried to downgrade the flutter sdk version but it is a bad idea

Upvotes: 0

Views: 326

Answers (4)

Sharath Appesh
Sharath Appesh

Reputation: 51

Temporarily revert build.gradle.kts file to build.gradle, Example below

mv android/settings.gradle.kts android/settings.gradle 
mv android/build.gradle.kts android/build.gradle
mv android/app/build.gradle.kts android/app/build.gradle

Command flutterfire configure will work properly

After the configuration is complete, you can rename the file back to build.gradle.kts, Example below

mv android/settings.gradle android/settings.gradle.kts 
mv android/build.gradle android/build.gradle.kts
mv android/app/build.gradle android/app/build.gradle.kts

Upvotes: 1

Handelika
Handelika

Reputation: 412

you have to first login firebase from your terminal. You can see the steps from here

If you are logged in,

firebase logout

And then login again

firebase login

From firebase console add the project and follow the adding flutter app instructions.

dart pub global activate flutterfire_cli
flutterfire configure --project='project-name'

After you see firebase_options.dart in your system, you have to add this code to your main.dart

await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
);

Upvotes: -1

user28916490
user28916490

Reputation:

Try resting the config path and it should refresh and resolve the issue.

If not create empty file at the path or check for permissions

Install or update the FlutterFire CLI:

dart pub global activate flutterfire_cli

Upvotes: 0

Ethical Aniruddha
Ethical Aniruddha

Reputation: 11

I just changed the channel to stable and it works :)

Upvotes: 0

Related Questions