巧用gradle来切换测试和正式服务器

2016-05-23  本文已影响426人  woodnaonly

gradle.propertiees

DEBUG_HOST="http://192.168.1.108"
DEBUG_PAYHOST="http://192.168.1.108:2000"
RELEASE_HOST="http://www.baidu.com"
RELEASE_PAYHOST="http://pay.baidu.com"

bulid.gradle

buildTypes {
    debug {
    buildConfigField "String", "HOST", DEBUG_HOST
    buildConfigField "String", "PAYHOST", DEBUG_HOST
    }
    release{
    buildConfigField "String", "HOST", RELEASE_HOST
    buildConfigField "String", "PAYHOST", RELEASE_PAYHOST
    }
}

APIURL.java

private static String HOST = BuildConfig.HOST;
private static String PAYHOST = BuildConfig.PAYHOST;
//手机注册发送短信验证码
public static String USER_REGISTER_SEND_MOBILE_CODE = HOST + "/user/register/send/mobile/code";
//手机注册新用户
public static String USER_REGISTER_MOBILE = PAYHOST + "/user/register/mobile";

Gradle学习资料

上一篇下一篇

猜你喜欢

热点阅读