【Gradle】Build Multiple Android Variants in Groovy

Gradle Script

app/build.gradle

groovy 复制代码
flavorDimensions("market", "version")

productFlavors {
    create("HUAWEI") {
        dimension = "market"
        manifestPlaceholders["market"] = name
    }
    create("HONOR") {
        dimension = "market"
        manifestPlaceholders["market"] = name
    }
    create("1_0_0") {
        dimension = "version"
        versionCode = 6000
        versionName = "1.0.0"
        manifestPlaceholders["version"] = versionName
    }
    create("2_0_0") {
        dimension = "version"
        versionCode = 7000
        versionName = "2.0.0"
        manifestPlaceholders["version"] = versionName
    }
}

buildTypes {
    debug {
        manifestPlaceholders = []
    }
}

variantFilter { variant ->
    if (variant.buildType.name.endsWith('release')) {
        variant.setIgnore(true)
    }
}

applicationVariants.all { variant ->
    def market = variant.productFlavors.find { it.dimension == "market" }.name
    def version = variant.productFlavors.find { it.dimension == "version" }.name.replaceAll("_", ".")
    variant.outputs.all { output ->
        output.outputFileName = "${market}-${version}.apk"
    }
}
Build Multiple Apks

Build - Generate Signed APK

相关推荐
Y40900111 分钟前
数据库基础知识——聚合函数、分组查询
android·数据库
没有了遇见5 小时前
Android 原生定位(替代高德 / 百度等三方定位)<终极版本>
android
2501_916008896 小时前
iOS 抓包工具有哪些?全面盘点主流工具与功能对比分析
android·ios·小程序·https·uni-app·iphone·webview
2501_915921436 小时前
iOS混淆工具实战 视频流媒体类 App 的版权与播放安全保护
android·ios·小程序·https·uni-app·iphone·webview
CYRUS_STUDIO6 小时前
LLVM 全面解析:NDK 为什么离不开它?如何亲手编译调试 clang
android·编译器·llvm
CYRUS_STUDIO6 小时前
静态分析神器 + 动态调试利器:IDA Pro × Frida 混合调试实战
android·逆向
g_i_a_o_giao9 小时前
Android8 binder源码学习分析笔记(一)
android·java·笔记·学习·binder·安卓源码分析
翻滚丷大头鱼9 小时前
android 四大组件—BroadcastReceiver
android
人生游戏牛马NPC1号9 小时前
学习 Android (二十) 学习 OpenCV (五)
android·opencv·学习
2501_9160088910 小时前
uni-app iOS 日志与崩溃分析全流程 多工具协作的实战指南
android·ios·小程序·https·uni-app·iphone·webview