处理构建类型
Gradle的android插件默认支持两种不同类型的构建类型:debug和release。可以通过模块构建文件中的buildTypes定制配置。
1 2 3 4 5 6 7 8 9 10 11
| buildTypes { release { minifyEnabled true shrinkResource true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } debug { applicationIdSuffix '.debug' versionNameSuffix '-debug' } }
|
通过在debug构建类型中配置applicationIdSuffix和versionNameSuffix可以在同一台设备上安装发布版本和调试版本
另外一个构建类型属性debuggable,调试构建类型自动设置为true,其他类型默认为false。
产品定制和变种
定制允许构建同一个App的多个版本,可以使用productFlavors来声明定制产品
1 2 3 4 5 6 7 8 9 10
| android { productFlavors { arrogant { applicationId 'xxxx' } friendly { applicationId 'xxxxxx' } } }
|