简体   繁体   English

具有多个项目的 Firebase google-services.json?

[英]Firebase google-services.json with multiple projects?

For our app I am using two different firebase projects:对于我们的应用程序,我使用了两个不同的 Firebase 项目:

  • Live: Contains the live iOS & Android app Live:包含实时 iOS 和 Android 应用程序
  • Test: Contains all our iOS & Android testing apps测试:包含我们所有的 iOS 和 Android 测试应用

As far as I could see the google-services.json (Android) contains the firebase project information and all related apps (as "client").据我所知,google-services.json (Android) 包含 firebase 项目信息和所有相关应用程序(作为“客户端”)。 Is it supported to add a second "project_info" into this file?是否支持在此文件中添加第二个“project_info”?

Why don't you try android application flavors, for that Google just included support for flavors on version 2.0 of the play services plugin.为什么不尝试android应用程序风格,因为谷歌刚刚在播放服务插件的2.0版中包含了对风格的支持。 Since this version of the gradle plugin com.google.gms:google-services:2.0.0-alpha3由于此版本的gradle plugin com.google.gms:google-services:2.0.0-alpha3

you can do this你可以这样做

app/src/ flavor1/google-services.json flavor2/google-services.json Version 3.0.0 of the plugin will search for the json file in these locations (considering you have a flavor flavor1 and a build type debug): app/src/flavor1/google-services.json flavor2/google-services.json 插件的 3.0.0 版将在这些位置搜索 json 文件(考虑到你有一个 flavor1 和一个构建类型调试):

/app/src/flavor1/google-services.json
/app/src/flavor1/debug/google-services.json
/app/src/debug/google-services.json
/app/src/debug/flavor1/google-services.json
/app/google-services.json

This worked for me even using flavorDimensions.即使使用了flavorDimensions,这也对我有用。 I have free & paid in one dimension and Mock & Prod in the other dimension.我在一个维度上有免费和付费,在另一个维度上有模拟和生产。 I also have 3 buildTypes: debug, release and staging.我也有 3 种构建类型:调试、发布和暂存。

How many google-services.json files will depend on your project's characteristics, but you will need at least one json file for every Google project. google-services.json 文件的数量取决于您的项目特征,但您至少需要为每个 Google 项目提供一个 json 文件。

If you want more details about what this plugin does with these json files, here it is: https://github.com/googlesamples/google-services/issues/54#issuecomment-165824720如果您想了解有关此插件如何处理这些 json 文件的更多详细信息,请访问: https : //github.com/googlesamples/google-services/issues/54#issuecomment-165824720

Link to the official docs: https://developers.google.com/android/guides/google-services-plugin官方文档链接: https : //developers.google.com/android/guides/google-services-plugin

And go here to check the latest version of this plugin: https://bintray.com/android/android-tools/com.google.gms.google-services/view并去这里检查这个插件的最新版本: https : //bintray.com/android/android-tools/com.google.gms.google-services/view

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 FirebaseMessaging 不使用 google-services.json 来支持多个项目 - FirebaseMessaging without using google-services.json to support multiple projects 适用于Firebase和Google Analytics(分析)的google-services.json - google-services.json for Firebase and Google Analytics Firebase:google-services.json 错误 - Firebase: google-services.json error Firebase google-services.json文件 - Firebase google-services.json file 离子Firebase指定google-services.json - Ionic firebase specify google-services.json 没有 google-services.json 和 google play 服务的 Firebase crashlytics - Firebase crashlytics without google-services.json and google play services Flutter for Firebase 中使用 buildTypes 的多个构建环境(多个 google-services.json) - Multiple Builds Environment in Flutter for Firebase Using buildTypes (multiple google-services.json) Firebase多个应用程序风味未调用相同的google-services.json文件onTokenRefresh() - Firebase multiple app flavors same google-services.json file onTokenRefresh() not called Firebase反编译Google-services.json填充quata - Firebase decompiled Google-services.json to fill quata Android Firebase身份验证:是否仍需要“ google-services.json”? - Android Firebase Auth: is “google-services.json” still required?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM