Dynamically generating product flavors

后端 未结 3 1262
南旧
南旧 2020-12-07 23:16

I\'ve created an Android App which needs to be build in many (30+) flavors.

My idea was to generate the different productFlavors directly from the folde

3条回答
  •  感情败类
    2020-12-07 23:55

    Solved by trial and error:

    android {
    
        // let's assume these are return by a function which reads the filesystem
        def myFlavors = [
            flavor1: [
                packageName: "com.example.flavor1"
            ],
            flavor2: [
                packageName: "com.example.flavor2"
            ]
        ]
    
        productFlavors {
            myFlavors.each { name, config ->
                "$name" {
                    packageName config.packageName
                }
            }
        }
    
    }
    

提交回复
热议问题