Mehrdad Mehrdad - 5 months ago 15
Android Question

Create build types for product flavors

I'm looking for how can I create build types directory for flavors.

Right now I have 2 flavors called

dev
and
prod
and I want to create debug and release directories in
app/src
folder.

My
app/src
folder looks like this:

main
androidTest
test
release
debug


About what I'm trying to achive:

I'm trying to add a sufix to my package in debug mode. So I achived that in build types block. in addition I have set
minSdkVersion 21
in one of my flavors so that android gradle builds faster.

Answer

You can create directory that are the combination between build types and flavors naming them with this convention: buildtypeFlavor

For what you want to achieve you have to insert in your build.gradle file both build types configurations and flavors configurations.

android {
    buildTypes {
        debug {
            applicationIdSuffix '.debug'
        }
        release {

        }
    }

    productFlavors {
        dev {
            minSdkVersion 21
        }
        prod {

        }
    }
}

Now you can create dirs under src to have the combination of both, in this case: devDebug, devRelease, prodDebug, prodRelease

root
|___module
    |___src
        |__devDebug
        |__devRelease
        |__prodDebug
        |__prodDebug