How to set applicationid for different flavor and buildtype?

2.2k Views Asked by At

I have

2 flavors

  • flavor1
  • flavor2

and

5 buildtypes

  • dev
  • debug
  • uat
  • preprod
  • release

I would like to set full applicationId to be

  • com.example.flavor1dev
  • com.example.flavor1debug
  • com.example.flavor1uat
  • com.example.flavor1preprod
  • com.example.flavor1
  • com.example.flavor2.dev
  • com.example.flavor2.debug
  • com.example.flavor2.uat
  • com.example.flavor2.preprod
  • com.example.flavor2

I use kotlin-dsl ,Please help

1

There are 1 best solutions below

0
On

update your build.gradle to below

   android {
 
   flavorDimensions "flavors" , "enviornment"

    productFlavors {
        flavor1 {
            dimension "flavors"
             applicationId "com.example.flavor1"
         }
        flavour2 {
            dimension "flavors"
            applicationId "com.example.flavor2"
        }
        dev {
            dimension "enviornment"
            manifestPlaceholders.appName = "(DEV)"
            applicationIdSuffix 'dev'
        }
        debug {
            dimension "enviornment"
            manifestPlaceholders.appName = "(Debug)"
            applicationIdSuffix 'debug'
        }
        uat {
            dimension "enviornment"
            manifestPlaceholders.appName = "(UAT)"
            applicationIdSuffix 'uat'
        }
        preprod {
            dimension "enviornment"
            manifestPlaceholders.appName = "(PreProd)"
            applicationIdSuffix 'preProd'
        }
       release {
            dimension "enviornment"
            manifestPlaceholders.appName = "(your app name)"
        }
    }
}