flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

File google-services.json is missing.

Open sderungs99 opened this issue 3 years ago • 8 comments

Hi,

Not sure if this is missing in the documentation, or there is something wrong with my project, but when configuring my app using the flutterfire CLI, I keep getting the following error during Android building:

 File google-services.json is missing. The Google Services Plugin cannot function without it. 

My understanding was the this was required before the app could be configured for Firebase via the flutterfire CLI, but maybe I am wrong and in fact I still need to google-services.json file? If that is the case, then certainly this is not mentioned in the documentation :-)

Anybody can advise?

sderungs99 avatar Sep 05 '22 14:09 sderungs99

My understanding was the this was required before the app could be configured for Firebase via the flutterfire CLI,

This correct. With new dart only initialization, we don't need to do manual installation, as flutterfire configure writes the native config files to the root of our app.

File google-services.json is missing. The Google Services Plugin cannot function without it.

This isn't actually an error, but a warning log coming from native firebase sdk which you can safely ignore.

See this document for your reference.

With this, I am going ahead and closing. If you disagree, write in comments and I'll reopen it.

darshankawar avatar Sep 06 '22 06:09 darshankawar

Hi @darshankawar , thanks for coming back so quickly! The link you added refers to the iOS warning. I have no issue with building for iOS (without the google services file). What I am quoting above is an actual error while building for Android (flutter build appbundle). Here is a bigger snippet of the output:

💪 Building with sound null safety 💪

Running Gradle task 'bundleRelease'...                          

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processReleaseGoogleServices'.
> File google-services.json is missing. The Google Services Plugin cannot function without it. 
   Searched Location: 
  /home/runner/work/sglandtransport/sglandtransport/android/app/src/release/google-services.json
  /home/runner/work/sglandtransport/sglandtransport/android/app/src/google-services.json
  /home/runner/work/sglandtransport/sglandtransport/android/app/src/Release/google-services.json
  /home/runner/work/sglandtransport/sglandtransport/android/app/google-services.json

If google-services.json is truly not required anymore when using dart initialization, maybe someone could point me to what might be responsible for it to still look for this file?

sderungs99 avatar Sep 06 '22 13:09 sderungs99

Thanks for the feedback. Reopening.

darshankawar avatar Sep 07 '22 10:09 darshankawar

Can you provide your flutter doctor -v, pubspec.yaml ?

darshankawar avatar Sep 07 '22 10:09 darshankawar

Here you go.

flutter doctor -v:

Run flutter doctor -v
  flutter doctor -v
  flutter pub get
  flutter pub run build_runner build
  flutter build appbundle --release --build-number=$BUILD_NUMBER --build-name=$RELEASE_VERSION --dart-define=LTA_DATAMALL_API_KEY=*** --dart-define=BUILD_NAME=$RELEASE_VERSION
  shell: /usr/bin/bash -e {0}
  env:
    JAVA_HOME_1[2](https://github.com/bytecrumbs/sglandtransport/runs/8229010147?check_suite_focus=true#step:9:2).0.2_x64: /opt/hostedtoolcache/jdk/12.0.2/x64
    JAVA_HOME: /opt/hostedtoolcache/jdk/12.0.2/x64
    JAVA_HOME_12_0_2_X64: /opt/hostedtoolcache/jdk/12.0.2/x64
    FLUTTER_ROOT: /opt/hostedtoolcache/flutter/stable-[3](https://github.com/bytecrumbs/sglandtransport/runs/8229010147?check_suite_focus=true#step:9:3).3.0-x64
    PUB_CACHE: /opt/hostedtoolcache/flutter/stable-3.3.0-x64/.pub-cache
    BUILD_NUMBER: 1662557165
    RELEASE_VERSION: 2.1.0
  
  ╔════════════════════════════════════════════════════════════════════════════╗
  ║                 Welcome to Flutter! - https://flutter.dev                  ║
  ║                                                                            ║
  ║ The Flutter tool uses Google Analytics to anonymously report feature usage ║
  ║ statistics and basic crash reports. This data is used to help improve      ║
  ║ Flutter tools over time.                                                   ║
  ║                                                                            ║
  ║ Flutter tool analytics are not sent on the very first run. To disable      ║
  ║ reporting, type 'flutter config --no-analytics'. To display the current    ║
  ║ setting, type 'flutter config'. If you opt out of analytics, an opt-out    ║
  ║ event will be sent, and then no further information will be sent by the    ║
  ║ Flutter tool.                                                              ║
  ║                                                                            ║
  ║ By downloading the Flutter SDK, you agree to the Google Terms of Service.  ║
  ║ Note: The Google Privacy Policy describes how data is handled in this      ║
  ║ service.                                                                   ║
  ║                                                                            ║
  ║ Moreover, Flutter includes the Dart SDK, which may send usage metrics and  ║
  ║ crash reports to Google.                                                   ║
  ║                                                                            ║
  ║ Read about data we send with crash reports:                                ║
  ║ https://flutter.dev/docs/reference/crash-reporting                         ║
  ║                                                                            ║
  ║ See Google's privacy policy:                                               ║
  ║ https://policies.google.com/privacy                                        ║
  ╚════════════════════════════════════════════════════════════════════════════╝
Running "flutter pub get" in flutter_tools...                       [4](https://github.com/bytecrumbs/sglandtransport/runs/8229010147?check_suite_focus=true#step:9:4).1s
[✓] Flutter (Channel stable, 3.3.0, on Ubuntu 20.04.[5](https://github.com/bytecrumbs/sglandtransport/runs/8229010147?check_suite_focus=true#step:9:5) LTS 5.15.0-1019-azure, locale C.UTF-8)
    • Flutter version 3.3.0 on channel stable at /opt/hostedtoolcache/flutter/stable-3.3.0-x[6](https://github.com/bytecrumbs/sglandtransport/runs/8229010147?check_suite_focus=true#step:9:6)4
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ffccd96b62 (9 days ago), 2022-08-29 1[7](https://github.com/bytecrumbs/sglandtransport/runs/8229010147?check_suite_focus=true#step:9:7):2[8](https://github.com/bytecrumbs/sglandtransport/runs/8229010147?check_suite_focus=true#step:9:8):57 -0700
    • Engine revision 5e[9](https://github.com/bytecrumbs/sglandtransport/runs/8229010147?check_suite_focus=true#step:9:9)e0e0aa8
    • Dart version 2.18.0
    • DevTools version 2.15.0
[!] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /usr/local/lib/android/sdk
    • Platform android-33, build-tools 33.0.0
    • ANDROID_HOME = /usr/local/lib/android/sdk
    • ANDROID_SDK_ROOT = /usr/local/lib/android/sdk
    • Java binary at: /opt/hostedtoolcache/jdk/12.0.2/x64/bin/java
    • Java version OpenJDK Runtime Environment Zulu12.3+11-CA (build 12.0.2+3)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
[✓] Chrome - develop for the web
    • Chrome at google-chrome
[✗] Linux toolchain - develop for Linux desktop
    • Ubuntu clang version 11.0.0-2~ubuntu20.04.1
    • cmake version 3.24.1
    ✗ ninja is required for Linux development.
      It is likely available from your distribution (e.g.: apt install ninja-build), or can be downloaded from https://github.com/ninja-build/ninja/releases
    • pkg-config version 0.29.1
    ✗ GTK 3.0 development libraries are required for Linux development.
      They are likely available from your distribution (e.g.: apt install libgtk-3-dev)
[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).
[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Ubuntu 20.04.5 LTS 5.15.0-[10](https://github.com/bytecrumbs/sglandtransport/runs/8229010147?check_suite_focus=true#step:9:10)[19](https://github.com/bytecrumbs/sglandtransport/runs/8229010147?check_suite_focus=true#step:9:20)-azure
    • Chrome (web)    • chrome • web-javascript • Google Chrome 105.0.5195.102
[✓] HTTP Host Availability
    • All required HTTP hosts are available
! Doctor found issues in 3 categories.

pubspec.yaml

name: lta_datamall_flutter
description: A new Flutter project.

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 2.0.0+500

environment:
  sdk: ">=2.17.0 <3.0.0"

dependencies:
  convex_bottom_bar: ^3.0.0
  dio: ^4.0.6
  drift: ^1.7.1
  firebase_analytics: ^9.3.3
  firebase_core: ^1.21.1
  firebase_crashlytics: ^2.8.9
  firebase_performance: ^0.8.2+4
  flare_flutter: ^3.0.2
  flutter:
    sdk: flutter
  flutter_hooks: ^0.18.5+1
  flutter_slidable: ^1.3.0
  flutter_staggered_animations: ^1.1.1
  freezed_annotation: ^2.1.0
  geolocator: ^9.0.1
  hooks_riverpod: ^1.0.4
  injectable: ^1.5.3
  json_annotation: ^4.6.0
  logger: ^1.1.0
  path: ^1.8.2
  path_provider: ^2.0.11
  pedantic: ^1.11.1
  rate_my_app: ^1.1.3
  share_plus: ^4.0.10+1
  shared_preferences: ^2.0.15
  sqlite3_flutter_libs: ^0.5.9
  substring_highlight: ^1.0.33
  url_launcher: ^6.1.5

dev_dependencies:
  build_runner: ^2.2.0
  drift_dev: ^1.7.0
  flutter_driver:
    sdk: flutter
  flutter_test:
    sdk: flutter
  freezed: ^2.1.0+1
  integration_test:
    sdk: flutter
  json_serializable: ^6.3.1

flutter_icons:
  android: true
  ios: true
  image_path: "images/app-icon.png"

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:
  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true
  assets:
    - images/city.flr
  # To add assets to your application, add an assets section, like this:
  # assets:
  #  - images/a_dot_burr.jpeg
  #  - images/a_dot_ham.jpeg
  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware.
  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages
  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  # fonts:
  #   - family: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages

sderungs99 avatar Sep 07 '22 13:09 sderungs99

Having the same problem.

enveraltin avatar Sep 07 '22 22:09 enveraltin

Thanks for the update. I looked at the setup documentation but didn't find reference for that issue: https://firebase.google.com/docs/flutter/setup?platform=android

The one that I found and referenced above is from old documentation and mostly for iOS: https://firebase.flutter.dev/docs/cli/#usage

Also, since this is occuring on Android, according to this old reference documentation, after initializing Flutterfire, it adds the Google services Gradle plugin automatically in build.gradle file.

Keeping this issue open for further insights on this behavior.

/cc @kevinthecheung @russellwheatley

darshankawar avatar Sep 08 '22 08:09 darshankawar

I'm experiencing the same issue: missing google-services.json file.

I'd like to support multiple environments via the code generated from the flutterfire configure command.

Now if i leave the prod version of the google-services.json file in, and pass the generated options for a dev environment to Firebase.initializeApp, i get a duplicateApp exception thrown in method_channel_firebase.dart line 134, because the apiKeys differs.

erf avatar Sep 15 '22 09:09 erf

Have you updated the FF CLI?

Run: dart pub global activate flutterfire_cli.

The service files are now written to the project for android & iOS as dart initialization was causing unforeseen problems.

russellwheatley avatar Sep 28 '22 11:09 russellwheatley

Hi @russellwheatley , I was on 0.2.4 and have now upgrade to the latest, which seems to be 0.2.6. However, running flutterfire configure on my project does not update anything. I guess that means it is still trying to do the same configuration. Can you elaborate more on your comment around "service files are now written to the project..."?

sderungs99 avatar Oct 02 '22 03:10 sderungs99

Your service file ought to be here android/app/google-services.json in your project directory after running flutterfire configure. Do you see it, @sderungs99?

russellwheatley avatar Oct 04 '22 10:10 russellwheatley

Oh, the CLI creates the google-services.json file in addition to the firebase_options.dart file now! Yes, I can see how it generates that file.

So in summary, to confirm my understanding:

  • For Android, both google-services.json as well as firebase_options.dart are needed, and the CLI creates both
  • For iOS, both GoogleService-Info.plist as well as firebase_options.dart are needed, and the CLI creates both

Correct?

And somehow related, is it safe to check-in the google-services.json and the GoogleService-Info.plist in my public repo? Or should flutterfire configure be executed as part of the build pipeline so the files get generated when building?

sderungs99 avatar Oct 04 '22 12:10 sderungs99

So in summary, to confirm my understanding:

For Android, both google-services.json as well as firebase_options.dart are needed, and the CLI creates both For iOS, both GoogleService-Info.plist as well as firebase_options.dart are needed, and the CLI creates both

firebase_options.dart - you can remove the android & iOS initialization code from here if you wish as your app will use the service files instead. You will need to keep web initialization config though if you have a web app.

And somehow related, is it safe to check-in the google-services.json and the GoogleService-Info.plist in my public repo? Or >should flutterfire configure be executed as part of the build pipeline so the files get generated when building?

Yes, the service files can be checked in. They don't hold any secrets. You ought to provide rules on your Firebase console to protect your services (e.g. Firestore, Storage, etc).

russellwheatley avatar Oct 04 '22 15:10 russellwheatley

Thank you, @russellwheatley! As far as I am concerned, this issue can be closed, unless you want to address @erf 's issue here has well?

sderungs99 avatar Oct 09 '22 01:10 sderungs99

Closing this based on above comment.

unless you want to address @erf 's issue here has well?

That sounds like an enhancement for flutterfire configure cli tool which is tracked in different repo.

darshankawar avatar Oct 10 '22 05:10 darshankawar

I'm facing the same issue

* What went wrong:
Execution failed for task ':app:processMockReleaseGoogleServices'.
> File google-services.json is missing. The Google Services Plugin cannot function without it.
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.3.4, on macOS 12.6 21G115 darwin-arm, locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] VS Code (version 1.72.0)
[✓] Connected device (4 available)
[✓] HTTP Host Availability

! Doctor found issues in 1 category.

What's the solution? Can someone mention it please?

balaji101010 avatar Oct 12 '22 12:10 balaji101010