Search code examples
androidandroid-studiobuild.gradleandroid-productflavors

Android Flavors


I need to combine two flavors that are available in my project and each flavor is divided for different aspects i.e one flavor for one functionality. All I need is to combine the two flavors such that i can have two functionalities in one build. Is there any method to combine two flavors? If there plz help me..thanks in advance.

 productFlavors {

       flavor1{
//for one functionality
        }

        flavor2{
//for second functionality
        }
        flavor3{
//for third functionality
        }
    }

Solution

  • After so much of research got an answer to my problem.The solution is as follows:

    sourceSets{

        flavor3{
            java.srcDirs 'src/flavor1/java','src/flavor2/java'
            res.srcDirs 'src/flavor1/res','src/flavor2/res'
        }
    }
    

    By doing so i can combine two flavors into single functionality as i wanted.