How do I maintain separate production settings for my Android apps?
I'm developing one of my first Android apps. I come from an ASP.NET world where it's trivial to have separate Web.config files for dev, test, and product开发者_StackOverflow中文版ion. Does anyone have a good, automated way of doing this for Android via Eclipse?
Have a command line ant based build system that takes "dev", "test", "production" as parameters and copies in the appropriate xml files for the build. This assumes that you already have a set of xml/config files for them.
I know question is late, but I will answer.
For have separate build for 'dev', 'test', 'production' you may use Gradle.
In build.gradle file you may define separate buildTypes
like this:
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debuggable false
versionNameSuffix "r"
}
debug {
versionNameSuffix "d"
debuggable true
}
test {
applicationIdSuffix ".test"
versionNameSuffix "t"
debuggable false
}
The above snippet achieves the following:
- config release, debug, and test builds
- set
versionNameSuffix
to refer to the version string which is build - set
applicationIdSuffix
for may install test and release build on one device - and most usefull Gradle Build Types can contribute to the build with resources: src/[buildtypename]/res. So you can have separate resource for separate builds.
For more info go to http://tools.android.com/tech-docs/new-build-system/user-guide
精彩评论