BuildConfig not getting created correctly (Gradle Android)

Please, be sure that you are building "dev" or "prod" variant. There is no BuildConfig definition in default "debug" and "release" variant. In Android Studio, you can select current variant in bottom left corner:

Build Variants

To simplify your build.gradle file, you can define:

buildTypes {
    debug {
        buildConfigField "String", "URL_SEARCH", "\"https://dev-search.example.com\""
        // etc.
    }
    release {
        buildConfigField "String", "URL_SEARCH", "\"https://search.example.com\""
        // etc.      
    }
}

and then just use default "debug" and "release" variants.

At last, delete semicolon (sign: ';') from the value of buildConfigField parameter.


I had same issue and fixed it like below:

buildConfigField 'String', 'BASE_URL', '"https://api.example.com"'