android lint error: missing translations in default locale
Fixes the Android lint MissingTranslation error when a string exists in a translated locale but not in the default values file. Add the string to values/strings.xml. Use when lint fails the build on missing default translations. Not for untranslatable strings.
android lint error: missing translations in default locale
TL;DR
Fixes the Android lint MissingTranslation error when a string exists in a translated locale but not in the default values file. Add the string to values/strings.xml. Use when lint fails the build on missing default translations. Not for untranslatable strings.
The error
Error: "promo_banner" is translated here but not found in default locale [MissingTranslation]Fix it
Step 1: Find the offending string
grep -rn "promo_banner" app/src/main/res/values-*/strings.xml | head -5Expected: You see which locale defines it and that values/strings.xml does not.
Step 2: Add it to the default locale
node -e "console.log('add promo_banner to app/src/main/res/values/strings.xml')"Expected: The default file now defines the string.
Step 3: Re-run lint
./gradlew lintDebug | tail -3Expected: Lint passes with no MissingTranslation errors.
When to use this
- Android lint fails on MissingTranslation
- A string was added to a translation but not to the default file
When NOT to use this
- The string should never be translated, mark it translatable false
- Lint warns but does not fail, check your lint severity config
Tool and version compatibility
- Android Gradle Plugin 8
- Any minSdk with resource shrinking
Variant phrasings
error after adding a new language
Translators delivered strings for keys the default file never had. Add them to default first.
string exists in default but lint still fails
A product flavor overrides values without the string. Check flavor resource sets.
Why it happens
Android falls back to the default locale for any missing translation, so every string must exist in values/. A string present only in values-de/ breaks that contract, and lint fails the build to catch it before release.
Edge cases
- translatable=false strings are exempt; use it for deliberate exceptions
- Library modules merge resources, so the missing default can live in a dependency
- Lint baselines can hide this error until the baseline is refreshed
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_u16i49zwg2rrtj9L0heGzQ