Skip to content Skip to sidebar Skip to footer

Change .properties File And Settings.gradle File In Android Project Based On Buildtype

I have a android gradle project where i have two buildTypes: QA and prod. I want to change a property in .properties file depending on the build type. I also want to change one of

Solution 1:

I'm not real sure what your goal is with the environment_name as its not used, but imagine you need to set a variable only for a specific build then you could do something like this:

ext {
    environment_name = null
}
android {
    // other stuff...
    buildTypes {
        qa {
            project.ext.environment_name = "qa"
        }
        prod {
            project.ext.environment_name = "prod"
        }
    }
}

// later you can use the variable like this
println "Hello variable: $project.ext.environment_name"

Using buildTypes should remove the need to modify the rootProject.name = 'tom-android'. Or you could use the productFlavors closure in the same way... depends on what all you want to specify explicitly for each build configuration.

Post a Comment for "Change .properties File And Settings.gradle File In Android Project Based On Buildtype"