【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

相关推荐
踢球的打工仔15 小时前
PHP面向对象(7)
android·开发语言·php
安卓理事人15 小时前
安卓socket
android
安卓理事人21 小时前
安卓LinkedBlockingQueue消息队列
android
万能的小裴同学1 天前
Android M3U8视频播放器
android·音视频
q***57741 天前
MySql的慢查询(慢日志)
android·mysql·adb
JavaNoober1 天前
Android 前台服务 "Bad Notification" 崩溃机制分析文档
android
城东米粉儿1 天前
关于ObjectAnimator
android
zhangphil1 天前
Android渲染线程Render Thread的RenderNode与DisplayList,引用Bitmap及Open GL纹理上传GPU
android
火柴就是我1 天前
从头写一个自己的app
android·前端·flutter
lichong9511 天前
XLog debug 开启打印日志,release 关闭打印日志
android·java·前端