Skip to content

Instantly share code, notes, and snippets.

@omegasoft7
Created December 19, 2018 15:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save omegasoft7/2e8b53bf177ecc52de14be0a6cfbe3f8 to your computer and use it in GitHub Desktop.
Save omegasoft7/2e8b53bf177ecc52de14be0a6cfbe3f8 to your computer and use it in GitHub Desktop.
Change String Resources from Gradle
applicationVariants.all { variant ->
variant.mergeResources.doLast {
def dir = new File("${buildDir}/intermediates/res/merged/${variant.dirName}") //iterating through resources, prepared for including to APK (merged resources)
println("Resources dir " + dir)
dir.eachFileRecurse { file ->
if(file.name.endsWith(".xml")) { //processing only files, which names and with .xml
String content = file.getText('UTF-8')
if(content != null && content.contains("Bill")) {
println("Replacing name in " + file)
content = content.replace("Bill", "Will") //replacing all Bill words with Will word in files
file.write(content, 'UTF-8')
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment