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="google-services.json" target="app/google-services.json" />
</platform>
这篇关于Ionic firebase 指定 google-services.json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Ionic firebase 指定 google-services.json


基础教程推荐
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01