File google-services.json is missing

Hi All,

I am using Ionic 2. In order to make use of Googles Push Notification Service, I need to install:

ionic plugin add cordova-plugin-fcm

However, after doing so, I get this error when I try build the app:

Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':processDebugGoogleServices'.
> File google-services.json is missing. The Google Services Plugin cannot function without it.
   Searched Location:
  E:\Development\IDE\ionic-apps\theWhoZoo\platforms\android\src\debug\google-services.json
  E:\Development\IDE\ionic-apps\theWhoZoo\platforms\android\google-services.json

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

So it appears to be missing the dependency google-services.json I think. Do I need to install it? How?

If anyone can assist I would appreciate it.

1 Like

Solution

I copied google-services.json to \platforms\android.

10 Likes

where did you find google-services.json ?

3 Likes

I just got this (or similar) issue because (I think) I updated phonegap-plugin-push to 2.0.0-rc3

Go to your project on https://console.firebase.google.com/
There you can add platform app. When you do that, there is the download button for google-services.json

5 Likes

Thanks i have found it

so according to installation documentation on https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/INSTALLATION.md#android-details

You should be get google-services.json from your Firebase console and put it in your root directory and then add this resource-file reference to config.xml :

<platform name="android">
  ...
  <resource-file src="google-services.json" target="google-services.json" />
</platform>
16 Likes

To download a config file
Sign in to Firebase and open your project.
Click the Settings icon and select Project settings.
In the Your apps card, select the package name of the app you need a config file for from the list.
Click google-services.json.

1 Like

For anyone using codova-android >= 7, you now must add

<platform name="android">
  <resource-file src="google-services.json" target="app/google-services.json" />
</platform>
17 Likes

iam using ionic v1. and i had included the required lines in the build.grade file. what should i do next?

Is the same required for iOS? Should it be copied to the \platforms\ios

All are saying place google services.json in root directory. Is the ‘root directory’ have no path name??

Root directory is your project directory which you use to create your Ionic app.
It means if you create your app in directory as ‘G:/Projects/XYZApp/’ then your root directory will be ‘G:/Projects/XYZApp/’. Copy your file here and change the config.xml as answered by HugoHeneault.
A workaround would be to copy google-services.json file into the directory ‘G:/Projects/XYZApp/platforms/android/app/’, but it will require you to copy the file into this directory each time you build your app. So the option to add it in your root directory and change the preference of app in config.xml is preferable.