Gradle: Multi-Dimension Flavor ApplicationId

后端 未结 3 1598
名媛妹妹
名媛妹妹 2021-01-05 03:05

I have a relatively complicated project that requires two flavor dimensions for each app. I\'ve rewritten it much more simply in the example below:

flavorDim         


        
3条回答
  •  失恋的感觉
    2021-01-05 03:09

    Gradle has an extras property built in, so you could do this without defining a class.

    Would look something like this, might have made a typo or two:

    productFlavors {
        blue {
            flavorDimension "color"
            ext.squareId = "yourAppId"
            ext.circleId = "yourAppId"
        }
    
        android.applicationVariants.all { variant ->
            def flavors = variant.getFlavors()
            if (flavors[0].name.equals("square")){
                variant.mergedFlavor.setApplicationId(flavors[1].ext.squareId)
            } ...
        }
    

提交回复
热议问题