Or Betzalel
Or Betzalel

Reputation: 2597

Ionic firebase specify google-services.json

I have an ionic 3 project and I wanted to add firebase to the project.

I installed the firebase cordova plugin and placed my google-services.json in resources/android but I get an error while parsing google-services.json : No matching client found for package name [name here]

When I look at my google-services.json that I put in resources/android the package name is correct but when I look in platforms/android the file is completely different and the package name is com.github.cordova_plugin_firebase

Anyone know how can make sure the correct google-services.json is used?

Upvotes: 1

Views: 9967

Answers (1)

Aniruddh Thakor
Aniruddh Thakor

Reputation: 1616

Try this steps.

  1. first remove your android platform to your project using ionic cordova platform remove android

  2. copy google-services.json file to the root directory (where package.json/config.xml file).

  3. then try to add android platoform using ionic cordova platform add android.then check your android folder google-services.json file copied automatically,if not then copy it to the android folder.

  4. Then check your build.gradle fileto include the google-services plugin and the Google's Maven repository:

    buildscript{
       //add dependencies as per your google-service version
     dependencies {
         classpath 'com.google.gms:google-services:4.2.0' // google-services plugin 
     }
    
     allprojects {
       repositories {
           google() // Google's Maven repository
     }
    }
    
  5. Then, in your module Gradle file (app/build.gradle), add the apply plugin line at the bottom of the file to enable the Gradle plugin

    dependencies {
        implementation 'com.google.firebase:firebase-core:16.0.7'
     }
    
    // ADD THIS AT THE BOTTOM
    apply plugin: 'com.google.gms.google-services'
    

Note:If you are using codova-android >= 7, you now must add

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

Upvotes: 6

Related Questions