dennis ayson
dennis ayson

Reputation: 171

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

I am using FCM for push notification I always get this error message

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

on phone I have placed my google-services.json on every folder and nothings working

Upvotes: 17

Views: 32025

Answers (9)

Steve Nginyo
Steve Nginyo

Reputation: 301

Add google-services.json file where the config.xml file is

Then add this line to the config.xml file

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

Then go to Project/platforms/android and add the google-services.json file

Upvotes: 0

Prais
Prais

Reputation: 969

Fist of all you need to download google-services.json:

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

(https://support.google.com/firebase/answer/7015592)

Ok now you have to install cordova-support-google-services:

cordova plugin add cordova-support-google-services --save

Then, you have to put the google-services.json in the root of your project (outside www folder, at the same level), and then the resource-file tag will copy it to platforms/android/app/

Next, put in the config.xml

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

Note: if you use cordova-android below version 7 specify instead:

target="google-services.json"

Now try again to build!

Upvotes: 23

Alireza Yazdani
Alireza Yazdani

Reputation: 1

Copy your google-services.json inside of your ionicProject/src then try to remove and reinstall the ionic-firebase plugin again.

Upvotes: 0

azerto00
azerto00

Reputation: 1000

Lets' assume you put the google-services.json in src/app folder So relativly to your ionic project it is located at src/app/google-services.json

Now, to be sure it will be copied to the correct location of the build, you have to add a line of code to the config.xml file.

<resource-file src="src/app/google-services.json" target="app/google-services.json" />

Note that the src property of this line should reflect the relative path of the google-service.json file accordingly.

That's as simple as that

Upvotes: 2

Mijoe
Mijoe

Reputation: 256

You have to copy the google-services.json file into platforms/android/app folder. Executing a android run will work fine.

(You can download the google-services.json from firbase project settings.

Upvotes: 0

Ranjit Singh Shekhawat
Ranjit Singh Shekhawat

Reputation: 519

I have placed google-services.json in Platforms/Android/ folder and run ionic cordova build android. Its working.

Upvotes: 0

Daniel Brolli
Daniel Brolli

Reputation: 111

As mentioned before google-services.json needs to be copied to the proper location. the location changed recently to app/google-services.json. So the config.xml needs to be adapted accordingly to

<resource-file src="google-services.json" target="app/google-services.json" />

Upvotes: 11

HarshitG
HarshitG

Reputation: 2827

From your dropdown select

  • project
  • then go to app folder
  • then paste your file inside app folder.
  • clean build and rebuild again

enter image description here

Upvotes: 0

JanP
JanP

Reputation: 1581

Place the google-services.json file in your project's root and make sure it will be copied to the www directory by adding this line to the config.xml file (between the <platform name="android">...</platform> tags):

<resource-file src="google-services.json" target="google-services.json" />

then run ionic cordova prepare android again.

Upvotes: 1

Related Questions