gradle-experimental:0.1.0 buildConfigField

2019-05-07 03:12发布

问题:

Anyone know how to define buildConfigField in the experimental gradle plugin?

android.productFlavors {
    create("demo") {
        applicationId = 'com.anthonymandra.rawdroid'
        buildConfigField "String", FIELD_META, PROVIDER_META
    }

gives:

Error:Attempt to read a write only view of model of type 'java.lang.Object' given to rule 'model.android.productFlavors'

回答1:

With the buildType you can use a syntax like this:

android.buildTypes {
    debug {
        buildConfigFields.with {
            create() {
                type = "String"
                name = "FIELD_META"
                value = "PROVIDER_META"
            }
        }
    }
}

I am not sure if you can use the same syntax with flavors.