Search code examples
androidgradleandroid-gradle-pluginandroid-productflavors

How to build multiple apps in Android with only one project


I need to build multiple apps for our clients with just one project. I am currently doing it with product flavors in gradle. However, I am running across a problem. My apps must contain the same package name for the first two level. I mean to say that for example, all my apps should contain the package name com.ourcompany in their app package names. For example:

com.ourcompany.clienta.AppA
com.ourcompanu.clientb.AppB

I need a way to build these apps with totally different package names like for clientA, I could go like com.clientacompany.AppA, for client B, it will be like com.clientbcompany.AppB. Is it possible to do this?


Solution

  • Use applicationId:

    productFlavors {
        vanilla {
            applicationId "com.clientacompany.app.a"
        }
    
        chocolate {
            applicationId "com.clientbcompany.app.b"
        }
    }
    

    I do not recommend mixed case, which is why I eliminated that in the values.