【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

相关推荐
-优势在我1 分钟前
Android TabLayout 实现随意控制item之间的间距
android·java·ui
hedalei2 分钟前
android13修改系统Launcher不跟随重力感应旋转
android·launcher
Indoraptor1 小时前
Android Fence 同步框架
android
峥嵘life2 小时前
DeepSeek本地搭建 和 Android
android
叶羽西2 小时前
Android14 Camera框架中Jpeg流buffer大小的计算
android·安卓
jiasting2 小时前
Android 中 如何监控 某个磁盘有哪些进程或线程在持续的读写
android
AnalogElectronic4 小时前
问题记录,在使用android studio 构建项目时遇到的问题
android·ide·android studio
我爱松子鱼5 小时前
mysql之InnoDB Buffer Pool 深度解析与性能优化
android·mysql·性能优化
江上清风山间明月8 小时前
Flutter开发的应用页面非常多时如何高效管理路由
android·flutter·路由·页面管理·routes·ongenerateroute
子非衣11 小时前
MySQL修改JSON格式数据示例
android·mysql·json