Android多环境配置

Android开发中,通常会在不同网络环境(比如:开发环境、测试环境)之间的切换、一次打多个渠道包等需求,如何优雅的管理网络环境的配置?


productFlavors {

//开发环境

develop {

buildConfigField "int", "ENV_TYPE", "1"

applicationId 'om.soubu.walledemo.develop'

manifestPlaceholders = [

app_name: "开-WalleDemo",

app_icon: "@drawable/icon_develop"

]

}

//测试环境

check {

buildConfigField "int", "ENV_TYPE", "2"

applicationId 'om.soubu.walledemo.check'

manifestPlaceholders = [

app_name: "测-WalleDemo",

app_icon: "@drawable/icon_check"

]

}

//生产环境

product {

buildConfigField "int", "ENV_TYPE", "3"

applicationId 'com.soubu.walledemo.product'

manifestPlaceholders = [

app_name: "WalleDemo",

app_icon: "@drawable/icon_product"

]

}

}

}

你可能感兴趣的:(Android多环境配置)