How to configure Android project's build types in Gradle?
How to configure Android project's build types in Gradle?
A few days ago, our team needs to configure the Gradle's build scripts to auto build the project. Here is the requirement, to build three versions of app, release, development and test, from the command line.I found the ways from the following link, http://stackoverflow.com/questions/17197636/is-it-possible-to-declare-a-variable-in-gradle-usable-in-java
Actually, we can generate the Java constants and Android resources from the Gradle's build script:
1 Generate Java Constants
android { buildTypes { debug { buildConfigField "int", "FOO", "42" buildConfigField "String", "FOO_STRING", "\"foo\"" } release { buildConfigField "int", "FOO", "52" buildConfigField "String", "FOO_STRING", "\"bar\"" } } }
2 Generate Android resources
android { buildTypes { debug{ resValue "string", "app_name", "My App Name Debug" } release { resValue "string", "app_name", "My App Name" } } }
Comments
Post a Comment