android-studio - Gradle:一种基于另一种构建类型

标签 android-studio gradle android-gradle-plugin

我在Android Studio中有4种构建类型:

release
debug
kindle
kindle_debug

如何将两个kindle任务都设置为使用发布/调试中的相同数据并仅更改某些属性?

最佳答案

您可以使用initWith从另一个BuildType继承,如以下示例所示:

android {
[...]
   buildTypes {            
            debug {
                debuggable true
                buildConfigField "boolean", "IS_V2", "false"
            }
            debugV2 {
                initWith debug
                buildConfigField "boolean", "IS_V2", "true"
                applicationIdSuffix ".v2"
            }
      }
   }
}

然后从Android Studio中的Build Variants中选择debugV2。

另请参阅以下文档:http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Types

关于android-studio - Gradle:一种基于另一种构建类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23054602/

相关文章:

java - 队列运行时 Volley 发送请求

android - react-native运行Android构建错误-无法解决:com.android.support:appcompat-v7:26.0.2

web-services - ModuleVersionNotFoundException:无法解析外部依赖项org.apache.cxf:cxf-tools-wsdlto-databinding-jaxb

android - Android Studio添加gradle存储库给出 “Invalid variable name. Must start with a letter”

android - 为什么 "Remove Unused Resources"在 Android Studio 中找不到任何东西?

Android Studio gradle模块依赖错误

Gradle exec 命令行不适合我

android - 无法解析 R.drawable.file.xml

android - 将 Gradle 支持添加到 Eclipse

android - Gradle没有正确选择appcompat-v7:22.2.1