Search code examples
androidgradleandroid-gradle-pluginbuild.gradlegradle-experimental

gradle-experimental:0.1.0 buildConfigField


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'


Solution

  • 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.