【问题标题】:Computed resValue from buildType and flavor从 buildType 和 flavor 计算的 resValue
【发布时间】:2014-12-09 00:44:07
【问题描述】:

我的应用程序由三种构建类型组成:开发、阶段和发布。还有两种口味:p2p 和 pro。

在 build.gradle 中,我使用 resValue 为每种构建类型定义要使用的方案:

  • custom_url_dev
  • custom_url_stage
  • custom_url_prod

我还想按风格配置方案。比如:

  • custom_url_pro_dev
  • custom_url_p2p_dev
  • custom_url_pro_stage
  • custom_url_p2p_stage
  • custom_url_pro_prod
  • custom_url_p2p_prod

所以基本上,我需要根据当前构建类型和当前风格计算 resValue。 Gradle 可以做到这一点吗?或者有没有更好的方法来获得这个结果?

【问题讨论】:

    标签: android-studio android-gradle-plugin build.gradle android-productflavors


    【解决方案1】:

    这会更麻烦,但我认为您需要特定类型+风味的资源文件,并且您将在每个单独的文件中进行自定义。您的目录结构将如下所示:

    src
        main
        p2pDev
            res
                values
                    strings.xml
        proDev
            res
                values
                    strings.xml
        p2pStage
            res
                values
                    strings.xml
    
    ...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-07-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-18
      • 2017-05-26
      相关资源
      最近更新 更多