在大多数情况下,我的应用程序是一个围绕浏览器的简单应用程序。我怀疑常规应用程序存在同样的问题,但是当我部署我的应用程序进行测试时,我需要将其指向测试服务器,当我转向生产时我希望它在生产中。目前我们部署一个版本进行测试,更改一些配置,然后部署新版本,基本上跳过测试状态。似乎应该有一个非常简单的方法来做到这一点。
作为奖励,您是否也了解iOS方法。
答案 0 :(得分:1)
您可以配置build.gradle以自动解析构建类型:
android {
...
buildTypes {
def BOOLEAN = "boolean"
def TRUE = "true"
def FALSE = "false"
def LOG_HTTP_REQUESTS = "LOG_HTTP_REQUESTS"
def REPORT_CRASHES = "REPORT_CRASHES"
def ENABLE_VIEW_SERVER = "ENABLE_VIEW_SERVER"
def ENABLE_SHARING = "ENABLE_SHARING"
def DEBUG_IMAGES = "DEBUG_IMAGES"
debug {
...
buildConfigField BOOLEAN, LOG_HTTP_REQUESTS, TRUE
buildConfigField BOOLEAN, REPORT_CRASHES, FALSE
buildConfigField BOOLEAN, ENABLE_VIEW_SERVER, TRUE
buildConfigField BOOLEAN, ENABLE_SHARING, TRUE
buildConfigField BOOLEAN, DEBUG_IMAGES, TRUE
}
client {
...
buildConfigField BOOLEAN, LOG_HTTP_REQUESTS, TRUE
buildConfigField BOOLEAN, REPORT_CRASHES, TRUE
buildConfigField BOOLEAN, ENABLE_VIEW_SERVER, FALSE
buildConfigField BOOLEAN, ENABLE_SHARING, FALSE
buildConfigField BOOLEAN, DEBUG_IMAGES, FALSE
}
release {
...
buildConfigField BOOLEAN, LOG_HTTP_REQUESTS, FALSE
buildConfigField BOOLEAN, REPORT_CRASHES, TRUE
buildConfigField BOOLEAN, ENABLE_VIEW_SERVER, FALSE
buildConfigField BOOLEAN, ENABLE_SHARING, FALSE
buildConfigField BOOLEAN, DEBUG_IMAGES, FALSE
}
}
}