【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

相关推荐
没有了遇见2 小时前
Android 音乐播放器之MotionLayout实现View流畅变换
android
TheNextByte13 小时前
在 PC 和Android之间同步音乐的 4 种方法
android
君莫啸ོ3 小时前
Android基础-Activity属性 android:configChanges
android
TimeFine3 小时前
Android AI解放生产力(七):更丰富的AI运用前瞻
android
保持低旋律节奏4 小时前
linux——进程状态
android·linux·php
明川4 小时前
Android Gradle - ASM + AsmClassVisitorFactory插桩使用
android·前端·gradle
csdn12259873364 小时前
Android将应用添加到默认打开方式
android
百锦再5 小时前
京东云鼎入驻方案解读——通往协同的“高架桥”与“快速路”
android·java·python·rust·django·restful·京东云
成都大菠萝5 小时前
1-2-3 Kotlin与C++基础-JNI原理与使用
android
TimeFine5 小时前
Android AI解放生产力(六)实战:解放页面开发前的繁琐工作
android·架构