android field 类型,android - How to generate buildConfigField with String type - Stack Overflow

In my Android Studio project there are two build configuration with some buildConfigField:

buildTypes {

def SERVER_URL = "SERVER_URL"

def APP_VERSION = "APP_VERSION"

debug {

buildConfigField "String", SERVER_URL, "http://dev.myserver.com"

buildConfigField "String", APP_VERSION, "0.0.1"

}

release {

buildConfigField "String", SERVER_URL, "https://myserver.com"

buildConfigField "String", APP_VERSION, "0.0.1"

minifyEnabled false

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

}

}

I am getting and error as follows:

/path/to/generated/BuildConfig.java

Error:(14, 47) error: ';' expected

Error:(15, 47) error: ';' expected

the generated BuildConfig.java is as follows:

public final class BuildConfig {

public static final boolean DEBUG = Boolean.parseBoolean("true");

public static final String APPLICATION_ID = "com.mycuteoffice.mcoapp";

public static final String BUILD_TYPE = "debug";

public static final String FLAVOR = "";

public static final int VERSION_CODE = 1;

public static final String VERSION_NAME = "1.0";

// Fields from build type: debug

public static final String APP_VERSION = 0.0.1;

public static final String SERVER_URL = http://dev.mycuteoffice.com;

}

I think the APP_VERSION and SERVER_URL are not getting generated properly as being String type they do not have quotes.

I am not sure why it is being generated in such a way. Please let me know how can I resolve this issues.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值