Ionic firebase specify google-services.json

给你一囗甜甜゛ 提交于 2019-12-01 10:42:49

问题


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?


回答1:


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>


来源:https://stackoverflow.com/questions/54542694/ionic-firebase-specify-google-services-json

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!