Android projects can quickly get complicated with build types, product flavors, and strings scattered across more input files. Some of our users prefer to upload Android projects using the Localazy CLI tool and not our Android Gradle plugin.
We support both ways to do so, and each of them has its pros and cons. If you would preferably use the CLI approach, below is an example of the CLI configuration file for your Android projects.
đšī¸ Android CLI configuration example
{
// Configure access to Localazy.
"writeKey": "write-token-1000000-3000100",
"readKey": "read-token-1000000-3000100",
// Transformations help to correctly detect information about modules, flavors and build types.
"transformations": [
// Detect module from the file path and store it as ${android_module}.
{
"name": "android_module",
"source": "${path}",
"operations": [
"substringBefore: /src",
"substringAfter: ./"
]
},
// Detect product flavors from the file path and store it as ${android_flavors}.
{
"name": "android_flavors",
"source": "${path}",
"operations": [
"androidProductFlavors: gp am gn ha sa, free full auto"
]
},
// Detect build type from the file path and store it as ${android_type}.
{
"name": "android_btype",
"source": "${path}",
"operations": [
"androidBuildType: debug, release"
]
},
// Detect language from the path and store it as ${android_lang}.
// Language is automatically detected by the autodetection, but we wanted
// to show how to do it manually if necessary.
{
"name": "android_lang",
"source": "${path}",
"operations": [
"detectLang: android"
]
}
],
"upload": {
"type": "android",
"files": [
// Collect & upload source langauge files.
// They are always uploaded.
// Correctly configure product flavors, build types and modules with
// variables we calculate from the file path using transformations.
{
"pattern": "*/src/*/res/values/strings*.xml",
"productFlavors": "${android_flavors}",
"buildType": "${android_btype}",
"module": "${android_module}"
},
// Collect & upload all non-source language files.
// Only upload them for: localazy upload all
// Correctly configure product flavors, build types, modules and languages.
// Also, skip all files that are in the source language using conditions.
{
"group": "all",
"pattern": "*/src/*/res/values-*/strings*.xml",
"conditions": "!equals: ${android_lang}, inherited",
"lang": "${android_lang}",
"productFlavors": "${android_flavors}",
"buildType": "${android_btype}",
"module": "${android_module}"
}
]
},
// Because we took the extra care to upload files with correct product flavors,
// build types and modules, we can download and place them to the correct place
// easily using built-in variables.
"download": {
"files": "${module}/src/${androidFlavoredFolder}/res/values-${langAndroidRes}/${file}"
}
}
đ You might also like
Read more articles related to Android or Localazy CLI on our blog.
đ Further reading:
This is a companion discussion topic for the original entry at https://localazy.com/blog/localazy-cli-tips-complex-android-configuration