离子火力地堡指定google-services.json [英] Ionic firebase specify google-services.json
问题描述
我有一个ionic 3项目,我想为该项目添加Firebase.
I have an ionic 3 project and I wanted to add firebase to the project.
我安装了firebase cordova插件并将google-services.json放在resources/android
中,但是在解析google-services.json时出现错误:No matching client found for package name [name here]
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]
当我查看放在resources/android
中的google-services.json时,程序包名称正确,但是当我查看platforms/android
时,文件完全不同,程序包名称为com.github.cordova_plugin_firebase
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
任何人都知道如何确保使用正确的google-services.json?
Anyone know how can make sure the correct google-services.json is used?
推荐答案
尝试此步骤.
-
首先使用 ionic cordova平台删除android
将google-services.json文件复制到根目录(其中package.json/config.xml文件).
copy google-services.json file to the root directory (where package.json/config.xml file).
然后尝试使用 ionic cordova平台添加android 添加android平台,然后检查您自动复制的android文件夹google-services.json文件,如果没有,则将其复制到android文件夹.
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.
然后检查您的build.gradle文件以包括google-services 插件和Google的Maven存储库:
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
}
}
然后,在模块Gradle文件(app/build.gradle)中,在文件底部添加Apply插件行以启用Gradle插件
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'
注意:如果您使用的是codova-android> = 7,则现在必须添加
<platform name="android">
<resource-file src="google-services.json" target="app/google-services.json" />
</platform>
这篇关于离子火力地堡指定google-services.json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!