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

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

问题描述

基于此答案 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:

  • 使用测试后端的Dev应用
  • 使用生产后端的Dev应用
  • 使用测试后端(企业分布)的测试应用
  • 使用生产后端(企业分布)的测试应用
  • 使用生产后端(应用商店分布)的实时应用

我对android设置的想法:

My thoughts for the android setup:

buildTypes: debug_test debug_production //无需企业应用程序,因为任何设备上都可能存在未签名的应用程序 释放

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

调味料: myApp

flavors: myApp

感谢您的支持!

推荐答案

好吧,为了使用不同的后端,我不会指定比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:

  • 更多口味
  • 自定义构建配置字段(文档此处),
  • 组合多种产品口味(文档此处) .
  • more flavors,
  • custom build config fields (documentation here),
  • combine multiple product flavors (documentation here).

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

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

具有简单口味的方法

  • 构建类型:

  • Build types:

  • debug
  • release
  • debug
  • release

香料:

  • dev
  • test
  • live
  • dev
  • test
  • live

哪些会导致这些生成变体(您不必全部使用它们):

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

  • devDebug
  • devRelease
  • testDebug
  • testRelease
  • liveDebug
  • liveRelease
  • devDebug
  • devRelease
  • testDebug
  • testRelease
  • liveDebug
  • liveRelease

使用尺寸组合多种口味的方法

  • 香料尺寸:

  • Flavor dimensions:

  • backend
  • target
  • backend
  • target

构建类型:

  • debug
  • release
  • debug
  • release

香料:

  • target尺寸:
    • dev
    • test
    • live
    • target dimension:
      • dev
      • test
      • live
      • production
      • test
      • production
      • test

      哪些会导致这些生成变体(再次,您不必全部使用它们):

      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
      • 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天全站免登陆