I want to make all apk files for release to all stores, so I have to use a productFlavor
for each apk:
build.gradle
buildTypes {
release {
...
}
debug {
...
}
}
productFlavors {
red {
...
}
yellow {
...
}
}
outputs
appname_red_debug.apk
appname_red_release.apk
appname_yellow_debug.apk
appname_yellow_release.apk
and I know above codes can change apk's file name. But when I generate the signed apk, I have to choose only one productFlavor
. This way, the result is only specific to that productFlavor
.
: UPDATED
How can I make all apk files at once on commend line using assembleRelease? Is there anyone who knows about this?
You can always select multiple flavors from the list when generating signed apk after selecting build type. It will generate apks for all selected flavors for the given build type. I've done this several times.
How, you ask? Select one flavor and press Ctrl + A to select all flavors or Press Ctrl and select multiple flavors as you want.
Here is an screenshot of me doing it right now (flavor names masked):
Update: I explored a bit more and noticed that dragging mouse to select multiple items doesn't work here as in other tools. This is the reason for all the confusion and I think Google should enable selection that way otherwise the feature may remain unused by many users.
If you would like to use the command line you can use one of these commands:
All buildVariants
- ./gradlew assemble
All flavors for a buildType
- ./gradlew assembleDebug
- ./gradlew assembleRelase
All buildTypes for a flavor
- ./gradlew assembleRed
- ./gradlew assembleYellow
Only a buildVariant
- ./gradlew assembleRedDebug
- ./gradlew assembleRedRelease
- ./gradlew assembleYellowDebug
- ./gradlew assembleYellowRelease
Also you can change the apk name using
project.ext.set("archivesBaseName", "....");
For example
project.ext.set("archivesBaseName", "myApp."+ defaultConfig.versionName);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With