Ionic firebase specify google-services.json(Ionic firebase 指定 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 时出现错误:找不到与包匹配的客户端名字[这里的名字]
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 platform remove 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 platform add 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 plugin 行以启用 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="Z29vZ2xlLXNlcnZpY2VzLmpzb24=" target="app/google-services.json" />
</platform>
这篇关于Ionic firebase 指定 google-services.json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Ionic firebase 指定 google-services.json


- Android - 拆分 Drawable 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01