Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

flutter gen-l10n stops because it cannot read the ARB file

ErrorThe 'template-arb-file', app_en.arb, is not readable.

Short answer

flutter gen-l10n reads the template ARB file named in l10n.yaml before it generates anything, and stops when it cannot. The file may lack read permission, may not exist under that name, may sit outside the arb-dir folder, or its keys may not be valid Dart method names. The error line names which one it is.

  • Applies to Flutter 3.3x, Dart 3.x
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Run the generator on its own, so the error is the last thing printed, then compare it with l10n.yaml and the folder on disk.

    flutter gen-l10n
    cat l10n.yaml
    ls -l lib/l10n
  2. 2Match what you see, then jump to its fix

    1. 1The 'template-arb-file', ..., is not readable. Please ensure that the user has read permissions.The ARB file or its folder lacks read permissionFix
    2. 2The 'template-arb-file', ..., does not exist.l10n.yaml names a template file that is not thereFix
    3. 3The 'arb-dir' directory, '...', does not exist. Make sure that the correct path was provided.arb-dir points at a folder that does not existFix
    4. 4Invalid ARB resource name "..." in app_en.arb.A message key is not a valid Dart method nameFix

What does the error look like?

  • The 'template-arb-file', app_en.arb, is not readable.
  • The 'template-arb-file', app_en.arb, does not exist.
  • The 'arb-dir' directory, 'lib/l10n', does not exist.
  • The 'arb-dir' directory, 'lib/l10n', doesn't allow reading and writing.
  • Invalid ARB resource name

Cause 1 of 4

The ARB file or its folder lacks read permission

1Check

The tool inspects the file's permission bits before reading it. List the mode of the template file and of the folder that holds it, and compare them with the user you run Flutter as.

ls -l lib/l10n

2Fix

Give your user read access to the file, and read and write access to the arb-dir folder, which the tool also checks.

chmod u+r lib/l10n/app_en.arb
chmod u+rwx lib/l10n

3Verify

Run the generator again; it should finish without an error and write app_localizations.dart.

flutter gen-l10n

Confirmed by raw.githubusercontent.com

Did this fix it?

Cause 2 of 4

l10n.yaml names a template file that is not there

1Check

The template defaults to app_en.arb when l10n.yaml does not set it. Compare the name in l10n.yaml, letter for letter, with the files in the arb-dir folder.

grep -n "template-arb-file" l10n.yaml
ls lib/l10n

2Fix

Make the two agree: rename the file to the name l10n.yaml expects, or change template-arb-file to the name of the file you have.

# l10n.yaml
arb-dir: lib/l10n
template-arb-file: app_en.arb
output-localization-file: app_localizations.dart

3Verify

Run the generator again.

flutter gen-l10n

Confirmed by docs.flutter.dev

Did this fix it?

Cause 3 of 4

arb-dir points at a folder that does not exist

1Check

arb-dir is read relative to the project root and defaults to lib/l10n. A typo, or a folder that was moved while l10n.yaml stayed the same, makes the tool stop at once.

grep -n "arb-dir" l10n.yaml
ls -d lib/l10n

2Fix

Point arb-dir at the folder that really holds the .arb files, or move the files to the folder l10n.yaml names.

# l10n.yaml
arb-dir: lib/l10n

3Verify

Run the generator again.

flutter gen-l10n

Confirmed by docs.flutter.dev

Did this fix it?

Cause 4 of 4

A message key is not a valid Dart method name

1Check

Each key in the template becomes a getter or method name in the generated class, so it has to be a valid Dart identifier. Look for keys with hyphens, spaces or a leading digit. The error names the key.

grep -n "my-bad-key" lib/l10n/app_en.arb

2Fix

Rename the key in the template and in every translated file to a valid Dart name, for example camelCase, and update the code that calls it.

{
  "welcomeTitle": "Welcome",
  "@welcomeTitle": {
    "description": "Title on the first screen"
  }
}

3Verify

Run the generator and then the analyzer so the renamed getter is picked up everywhere.

flutter gen-l10n
flutter analyze

Confirmed by raw.githubusercontent.com

Did this fix it?

How do I stop it coming back?

  • Keep l10n.yaml, the arb-dir folder and the template file name in one commit, so a rename in one place cannot leave the others behind.
  • Name message keys in camelCase from the start; a key becomes a method name.
  • Run flutter gen-l10n in CI, so a broken l10n.yaml or a missing file fails the build early.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.