bazelbuild/bazel · error · RuntimeError

Invalid library proguard config parameters (these parameters

Error message

Invalid library proguard config parameters (these parameters are either invalid or only supported in android_binary rules): {invalid_configs}

What it means

Raised by proguard_allowlister.py, which validates proguard configs consumed by library rules (proguard specs attached to libraries, not android_binary). After stripping comments, it splits the config into dash-prefixed arguments and collects those whose head word is not in the allowed set ('keep', 'assumenosideeffects', 'assumevalues', 'adaptresourcefilecontents', 'if'); any remainder triggers RuntimeError listing the invalid_configs.

Source

Thrown at tools/jdk/proguard_allowlister.py:47


class ProguardConfigValidator(object):
  """Validates a proguard config."""

  # Must be a tuple for str.startswith()
  _VALID_ARGS = ('keep', 'assumenosideeffects', 'assumevalues',
                 'adaptresourcefilecontents', 'if')

  def __init__(self, config_path: str, outconfig_path: str):
    self._config_path = config_path
    self._outconfig_path = outconfig_path

  def ValidateAndWriteOutput(self):
    with open(self._config_path) as config:
      config_string = config.read()
      invalid_configs = self._Validate(config_string)
      if invalid_configs:
        raise RuntimeError(
            'Invalid library proguard config parameters '
            '(these parameters are either invalid or only supported in '
            'android_binary rules): ' + str(invalid_configs))
    with open(self._outconfig_path, 'w+') as outconfig:
      config_string = '# Merged from %s \n%s' % (
          self._config_path, config_string)
      outconfig.write(config_string)

  def _Validate(self, config: str) -> Sequence[str]:
    """Checks the config for illegal arguments."""
    config = re.sub(PROGUARD_COMMENTS_PATTERN, '', config)
    args = re.compile('(?:^-|\n-)').split(config)

    invalid_configs = []
    for arg in args:
      arg = arg.strip()
      if not arg or self._ValidateArg(arg):
        continue

View on GitHub (pinned to e6e199d060)

Solutions

  1. Remove the listed invalid options from the library's proguard spec — the error names them exactly.
  2. Move app-level options (obfuscation/shrinking/mapping controls) to the android_binary target's proguard spec.
  3. Keep only class-retention directives (-keep and friends from the allowlist) in library specs.

Example fix

# library proguard.cfg — before
-keep class com.example.Api { *; }
-dontobfuscate
-apply-mapping old-mapping.txt

# after (library keeps only allowlisted directives)
-keep class com.example.Api { *; }
# move -dontobfuscate / -apply-mapping to the android_binary proguard spec
Defensive patterns

Strategy: validation

Validate before calling

_VALID = ('keep', 'assumenosideeffects', 'assumevalues', 'adaptresourcefilecontents', 'if')
import re
args = re.compile('(?:^-|\n-)').split(re.sub(PROGUARD_COMMENTS_PATTERN, '', config_string))
invalid = [a for a in args if a.split() and a.split()[0] not in _VALID]  # check before wiring the spec in

Prevention

When it happens

Trigger: A proguard_proguard.cfg (or spec) applied to a library rule containing options outside the allowlist — e.g. '-dontobfuscate', '-dontshrink', '-apply-mapping', '-keepdirectories', '-printconfiguration' — all of which only make sense on android_binary's own spec.

Common situations: Copying a full app-level proguard config into a library's proguard.cfg; migrating a monolithic app into libraries without splitting the proguard spec; third-party AAR specs carrying app-level options.

Related errors


AI-assisted analysis of bazelbuild/bazel@e6e199d060 (2026-08-14). Data as JSON: /api/errors/61e5026f992066be. Report an issue: GitHub.