1 year ago

#185643

test-img

Robertoq

Android Gradle: applicationIdSuffix dynamically by productFlavor

I wanna set the applicationIdSuffix dynamically flavorDimension value. How can I add condition? here is my example:

flavorDimensions "company", "environment"


productFlavors {
    company_one {
        dimension "company"
        applicationId = "company.one"
    }
    company_two {
        dimension "company"
        applicationId = "company.two"
    }


    // ENVIRONMENTS
    prod {
        dimension "environment"
        applicationIdSuffix if (company == "company.one") "1" else "2"
    }
    // TST
    tst {
        dimension "environment"
        applicationIdSuffix '.tst'
    }

I wanna use variantFilter and tried variant.mergedFlavor.setApplicationId but not available. Also tried variant.defaultConfig but I gave ReadOnlyProductFlavor and I can't modify it.

android

gradle

android-productflavors

0 Answers

Your Answer

Accepted video resources