Search code examples
androidandroid-gradle-pluginapkbuild.gradleandroid-productflavors

Android Studio: How to generate multiple APKs or signed APKs for all productFlavors at once for a selected buildType?


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?


Solution

  • 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):

    enter image description here

    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.