在我的Android Studio
项目中有两个build configuration
与一些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'
}
}
我得到和错误如下:
/path/to/generated/BuildConfig.java
Error:(14, 47) error: ';' expected
Error:(15, 47) error: ';' expected
生成BuildConfig.java
如下:
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;
}
我认为APP_VERSION
和SERVER_URL
没有得到正确的生成,因为它们是String类型,没有引号。
我不确定为什么会以这种方式生成它。请让我知道如何解决此问题。
buildConfigField "String", APP_VERSION, ' "0.0.1" '
当然不能有空格)