Gradle for Android, how to replace content with XML files for this option

I am brand new with Gradle and I don't have much experience with Maven.

I have a build script that creates different options and different versions (debug, preprod, release).

I already changed the values ​​dynamically using the buildConfig class, but now I need the DEBUG value for ERROR in the production version in both variants of src / main / res / xml / config.xml.

config.xml file:

<?xml version="1.0" encoding="utf-8"?>
<log level="DEBUG"/>

build.gradle file:

task wrapper(type: Wrapper) {
gradleVersion = '1.8'
}

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}


android {
    compileSdkVersion 18
    buildToolsVersion "19.0.1"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 19
        versionName "1.0"
    }

    signingConfigs {
        release {
            storeFile file("keystore")
            storePassword "xxx"
            keyAlias "xxx"
            keyPassword "xxx"
        }

        preprod {
            storeFile file("keystore")
            storePassword "xxx"
            keyAlias "xxx"
            keyPassword "xxx"
        }
    }



    buildTypes {

        debug {
            def variable_1 = 'xxx'

            buildConfig "public static final String VARIABLE_1 = \"$variable_1\";";
        }

        preprod {
            def variable_1 = 'yyy'

            buildConfig "public static final String VARIABLE_1 = \"$variable_1\";";
        }

        release {
            def variable_1 = 'zzz'

            buildConfig "public static final String VARIABLE_1 = \"$variable_1\";";
            signingConfig signingConfigs.releas
        }

        productFlavors {

            one {
                packageName "com.test.one"
            }

            two {
                packageName "com.test.two"
            }
        }



        android.sourceSets.one{

            res {
                srcDir 'one'
            }

            assets {
                srcDir 'one/assets'
            }

            manifest {
                srcFile "src/one/AndroidManifest.xml"
            }

        }

        android.sourceSets.two {
            res {
                srcDir 'two'
            }

            assets {
                srcDir 'two/assets'
            }

            manifest {
                srcFile "src/two/AndroidManifest.xml"
            }

        }
    }


}

dependencies {
    compile files('libs/android-support-v4.jar')
}
+3
source share

All Articles