问题
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.
first remove your android platform to your project using ionic cordova platform remove android
copy google-services.json file to the root directory (where package.json/config.xml file).
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.
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 } }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