Android Studio で Gradle プロジェクトを開いたとき、なにも指定がなければ、buildType / productFlavor を辞書順で並べたときの先頭の組が選択されます。
初期選択したい buildType / productFlavor があれば isDefault を設定します。
- Android Gradle Plugin 7.0.4 で確認しています
設定
app/build.gradle.kts
android {
// ...
buildTypes {
getByName("debug") {
isDefault = true
// ...
}
register("release") {
// ...
}
}
productFlavors {
register("develop") {
isDefault = true
// ...
}
register("alpha") {
// ...
}
register("production") {
// ...
}
}
// ...
}
デフォルトの buildType / productFlavor を指定するには ApplicationBuildType#isDefault と ApplicationProductFlavor#isDefault を設定します。
上記設定であれば、developDebug
がデフォルトとして選択されるようになります。
buildType が debug, release であり、productFlavor が alpha, develop, production であれば、Build Variant は以下のように辞書順で並びます。
- buildType: debug -> release
- productFlavor: alpha -> develop -> production
- Build Variant: alphaDebug -> alphaRelease -> developDebug -> developRelease -> productionDebug -> productionRelease
isDefault の設定がなければ、先頭の alphaDebug
がデフォルトで選択されます。