相关疑难解决方法(0)

如何使用String类型生成buildConfigField

在我的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'
    }
}
Run Code Online (Sandbox Code Playgroud)

我得到的错误如下:

/path/to/generated/BuildConfig.java
    Error:(14, 47) error: ';' expected
    Error:(15, 47) error: ';' expected
Run Code Online (Sandbox Code Playgroud)

生成的BuildCofig.java如下:

public final class BuildConfig {
    public static final boolean DEBUG = Boolean.parseBoolean("true");
    public static final String APPLICATION_ID = "com.mycuteoffice.mcoapp";
    public …
Run Code Online (Sandbox Code Playgroud)

android android-gradle-plugin

125
推荐指数
7
解决办法
6万
查看次数

标签 统计

android ×1

android-gradle-plugin ×1