Skip to content

Issue with BuildConfig generation #113

@dnorum63

Description

@dnorum63

I'm getting an error when building the App.

The error is:
error: cannot find symbol
boolean found = BuildConfig.TRANSLATION_ARRAY.length == 0;
^
symbol: variable TRANSLATION_ARRAY
location: class BuildConfig

It appears that there is code in the build.gradle that is supposed to generate this array:
task buildTranslationArray {
doLast {
def foundLocales = new StringBuilder()
foundLocales.append("new String[]{")

    fileTree("src/main/res").visit { FileVisitDetails details ->
        if(details.file.path.endsWith("strings.xml")){
            def languageCode = details.file.parent.tokenize('/').last().tokenize('\\').last().replaceAll('values-','').replaceAll('-r','-')
            languageCode = (languageCode == "values") ? "en" : languageCode;
            foundLocales.append("\"").append(languageCode).append("\"").append(",")
        }
    }

    foundLocales.append("}")
    def foundLocalesString = foundLocales.toString().replaceAll(',}','}')
    android.defaultConfig.buildConfigField "String[]", "TRANSLATION_ARRAY", foundLocalesString
}

}
preBuild.dependsOn buildTranslationArray

Are there any logs to check that show why this gradle code is not generating the array code in the BuildConfig.java file?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions