Firebase 2.0 - 如何处理 Android 应用程序的多种风格(环境)? [英] Firebase 2.0 - how to deal with multiple flavors (environments) of an android app?

查看:18
本文介绍了Firebase 2.0 - 如何处理 Android 应用程序的多种风格(环境)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用有多种风格.我应该如何设置服务器端?我的包名是:

I have multiple flavors of my app. How should I set this up server side? My package names are:

com.example.app(生产)com.example.app.staging(暂存)com.example.app.fake(假的)

com.example.app (production) com.example.app.staging (staging) com.example.app.fake (fake)

这应该是 firebase 控制台中的 3 个独立项目吗?

Should this be 3 separate projects in the firebase console?

推荐答案

很大程度上取决于您希望您的项目如何运作.您可以在同一个控制台中设置所有三个,也可以设置为两个或多个不同的项目.任一选项均有效.

Largely it will depend on how you want your project to work. You can set all three up in the same console, or you can set up as two or more different projects. Either option is valid.

同一个项目的好处:

  • 共享相同的计费、配额、权限和服务(数据库、存储、FCM 等).
  • 与生产相同的环境.

不同项目的好处:

  • 没有覆盖生产数据或影响生产用户的风险.

如果使用多个项目,您可以利用构建类型支持将允许您为不同的版本使用不同的 google-services.json 文件.如果使用一个项目,相同的 google-services.json 将适用于所有品种.

If using multiple projects, you can take advantage of the build types support which will allow you to have different google-services.json files for different versions. If using one project, the same google-services.json will work for all the varieties.

注意:正如 CodyMace 在评论中所说 - 记得每次添加应用程序时重新下载 JSON 文件!

Note: as CodyMace says in the comments - remember to re-download the JSON file each time you add an app!

在这两种情况下,您都可以采取一些措施来最大程度地降低风险(例如,在您的数据库中有 dev/stage/prod/键,并且下面有类似的结构),但对您来说有意义的主要是权衡.

There are things you can do to minimise risks in either case (e.g. have dev/ stage/ prod/ keys in your Database, and have similar structures underneath), but what makes sense for you is largely about tradeoffs.

如果您刚刚开始,我建议您在开发时从一个项目开始,一旦启动,请考虑将您的开发环境转移到一个单独的项目中.分期可以采用任何一种方式.

If you're just starting out, I would suggest starting with one project while you're in development, and once you've launched consider moving your development environment to a separate project. Staging could go either way.

这篇关于Firebase 2.0 - 如何处理 Android 应用程序的多种风格(环境)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆