Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with BuildConfig generation #113

Open
dnorum63 opened this issue Dec 23, 2023 · 2 comments
Open

Issue with BuildConfig generation #113

dnorum63 opened this issue Dec 23, 2023 · 2 comments

Comments

@dnorum63
Copy link

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?

@Chainfire
Copy link
Owner

Not that I know of. Gradle is an absolute nightmare and nothing works for more than 2 releases in a row.

@dnorum63
Copy link
Author

Thank you @Chainfire

I will keep playing with the code

-DN

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants