如何配置构建类型与产品风格? [英] How to configure build types vs. product flavors?

查看:22
本文介绍了如何配置构建类型与产品风格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基于这个答案 https://stackoverflow.com/a/27908019/5156317 我有一个后续问题:是什么让一款代表产品风味的应用与众不同?我正在尝试将此与我的 XCode 设置进行比较,如下所示:

Based on this answer https://stackoverflow.com/a/27908019/5156317 I have a follow up question: What makes an app different that speaks for product flavours? I am trying to compare this with my XCode setup which is as follows:

  • 使用测试后端的开发应用
  • 使用生产后端的开发应用
  • 使用测试后端的测试应用(企业发行版)
  • 使用生产后端的测试应用(企业分发
  • 使用生产后端的实时应用(应用商店分发)

我对 android 设置的想法:

My thoughts for the android setup:

构建类型:调试测试调试生产//不需要企业应用程序,因为任何设备上都可能有未签名的应用程序发布

buildTypes: debug_test debug_production // no need of enterprise apps since it is possible unsigned apps on any device release

口味:我的应用程序

感谢您的支持!

推荐答案

好吧,我不会指定比 debugrelease 更多的构建类型,以便使用不同的后端.相反,我会使用其中一些技术:

Well, I wouldn't specify more build types than debug and release in order to use different backend. Instead, I would use some of these techniques:

  • 更多口味,
  • 自定义构建配置字段(文档此处),
  • 结合多种产品风格(文档此处).

您可以使用 BuildConfig 类访问应用程序代码中的构建类型、构建风格和自定义字段.

You can access build types, build flavors and custom fields in the application code using BuildConfig class.

简单的方法

  • 构建类型:

  • Build types:

  • 调试
  • 发布

口味:

  • 开发
  • 测试
  • 直播

这会导致这些构建变体(您不必全部使用它们):

Which would result in these build variants (you don't have to use all of them):

  • devDebug
  • 开发发布
  • testDebug
  • testRelease
  • liveDebug
  • liveRelease

使用维度组合多种风格的方法

  • 风味维度:

  • Flavor dimensions:

  • 后端
  • 目标

构建类型:

  • 调试
  • 发布

口味:

  • 目标维度:
    • 开发
    • 测试
    • 直播
    • 生产
    • 测试

    这会导致这些构建变体(同样,您不必使用所有这些变体):

    Which would result in these build variants (again, you don't have to use all of them):

    • productionDevDebug
    • productionDevRelease
    • productionTestDebug
    • productionTestRelease
    • productionLiveDebug
    • productionLiveRelease
    • testDevDebug
    • testDevRelease
    • testTestDebug
    • testTestRelease
    • testLiveDebug
    • testLiveRelease

    使用构建字段

    在构建类型和构建风格声明中使用附加值,例如:

    Use additional value in build types and build flavors declarations, for example:

    buildConfigField "boolean", "production_backend", "false"

    buildConfigField "String", "backend", ""production""

    这篇关于如何配置构建类型与产品风格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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