weston
weston

Reputation: 54781

Where can I specify applicationId per-combination for a multi-flavor build?

android {

    flavorDimensions 'app', 'region'

    productFlavors {
        app1 {
            dimension 'app'
        }
        app2 {
            dimension 'app'
        }
        europe {
            dimension 'region'
        }
        asia {
            dimension 'region'
        }
}

Now I need:

I can't see a place that will allow me to specify the applicationId per for the flavor combination.

Note: As the client app store listings already exist, I can't have one listing for these multiple regions. There really isn't any common prefix among the application ids beyond com.

Upvotes: 2

Views: 319

Answers (1)

Shamm
Shamm

Reputation: 1004

android.applicationVariants.all { variant ->
    def mergedFlavor = variant.mergedFlavor
    switch (variant.flavorName) {
        case "app1Europe":
            mergedFlavor.setApplicationId("com.w")
            break
        case "app2Europe":
            mergedFlavor.setApplicationId("com.x")
            break
        case "app1Asia":
            mergedFlavor.setApplicationId("com.y")
            break
        case "app2Asia":
            mergedFlavor.setApplicationId("com.z")
            break
    }
}

Inspired by https://stackoverflow.com/a/28044024/2545800

Upvotes: 4

Related Questions