{"record":{"id":"61e5026f992066be","repo":"bazelbuild/bazel","slug":"invalid-library-proguard-config-parameters-these","errorCode":null,"errorMessage":"Invalid library proguard config parameters (these parameters are either invalid or only supported in android_binary rules): {invalid_configs}","messagePattern":"Invalid library proguard config parameters \\(these parameters are either invalid or only supported in android_binary rules\\): (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"tools/jdk/proguard_allowlister.py","lineNumber":47,"sourceCode":"\n\nclass ProguardConfigValidator(object):\n  \"\"\"Validates a proguard config.\"\"\"\n\n  # Must be a tuple for str.startswith()\n  _VALID_ARGS = ('keep', 'assumenosideeffects', 'assumevalues',\n                 'adaptresourcefilecontents', 'if')\n\n  def __init__(self, config_path: str, outconfig_path: str):\n    self._config_path = config_path\n    self._outconfig_path = outconfig_path\n\n  def ValidateAndWriteOutput(self):\n    with open(self._config_path) as config:\n      config_string = config.read()\n      invalid_configs = self._Validate(config_string)\n      if invalid_configs:\n        raise RuntimeError(\n            'Invalid library proguard config parameters '\n            '(these parameters are either invalid or only supported in '\n            'android_binary rules): ' + str(invalid_configs))\n    with open(self._outconfig_path, 'w+') as outconfig:\n      config_string = '# Merged from %s \\n%s' % (\n          self._config_path, config_string)\n      outconfig.write(config_string)\n\n  def _Validate(self, config: str) -> Sequence[str]:\n    \"\"\"Checks the config for illegal arguments.\"\"\"\n    config = re.sub(PROGUARD_COMMENTS_PATTERN, '', config)\n    args = re.compile('(?:^-|\\n-)').split(config)\n\n    invalid_configs = []\n    for arg in args:\n      arg = arg.strip()\n      if not arg or self._ValidateArg(arg):\n        continue","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/bazelbuild/bazel/blob/e6e199d0601a244511b4cf18c8b2828aa73db1fd/tools/jdk/proguard_allowlister.py#L29-L65","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Remove the listed invalid options from the library's proguard spec — the error names them exactly.","Move app-level options (obfuscation/shrinking/mapping controls) to the android_binary target's proguard spec.","Keep only class-retention directives (-keep and friends from the allowlist) in library specs."],"exampleFix":"# library proguard.cfg — before\n-keep class com.example.Api { *; }\n-dontobfuscate\n-apply-mapping old-mapping.txt\n\n# after (library keeps only allowlisted directives)\n-keep class com.example.Api { *; }\n# move -dontobfuscate / -apply-mapping to the android_binary proguard spec","handlingStrategy":"validation","validationCode":"_VALID = ('keep', 'assumenosideeffects', 'assumevalues', 'adaptresourcefilecontents', 'if')\nimport re\nargs = re.compile('(?:^-|\\n-)').split(re.sub(PROGUARD_COMMENTS_PATTERN, '', config_string))\ninvalid = [a for a in args if a.split() and a.split()[0] not in _VALID]  # check before wiring the spec in","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep library proguard specs limited to -keep-style retention rules.","Put obfuscation/shrinking/mapping options only in the android_binary spec.","Run proguard_allowlister in CI on every library spec change."],"tags":["proguard","android","build","validation"],"backgroundTag":null,"analyzedSha":"e6e199d0601a244511b4cf18c8b2828aa73db1fd","analyzedAt":"2026-08-14T10:24:27.848Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}