flavorDimension

标签: flavorDimension

android gradle flavorDimension的使用

先从字面来解读flavorDimension,flavor翻译为口味、特点,在gradle中用来实现不同的渠道包(可能packageName不一样,可能版本号,and so on),Dimension翻译为维度,flavorDimension就翻译成渠道的维度吧。先看一段代码: android { ... flavorDimensions "releaseType", "market" productFlavors { free { flavorDimension "releaseType" } pro { flavorDimension "releaseType" } china { flavorDimension "market" } global { flavorDimension "market" } } } 因为网上对于flavorDimension的资料是在太少,所以只能根据代码运行情况来分析作用了。 执行gradlew assembleRelease命令(linux/Mac下为./gradlew assembleRelease) 在build/outputs/apk下共生成了4个apk文件(都是unsigned的原因是我没有设置签名),分别为: app-free-china-release-unsigned.apk app-free-global-release-unsigned.apk app-pro-china-release-unsigned.apk app-pro-global-release-unsigned.apk

阅读全文...