{"record":{"id":"9eb1482285033ed5","repo":"bazelbuild/bazel","slug":"proguard-failed-p-returncode","errorCode":null,"errorMessage":"Proguard failed ({p.returncode})","messagePattern":"Proguard failed \\((.+?)\\)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"tools/build_defs/proguard/wrapper.py","lineNumber":101,"sourceCode":"      \"-outjars\",\n      output_jar,\n      \"@\" + proguard_spec,\n  ]\n\n  env = os.environ.copy()\n  env.update(r.EnvVars())\n  # print(\"Running proguard: %s\" % \" \".join(command))\n  p = subprocess.run(command, capture_output=True, env=env, check=False)\n\n  if p.returncode != 0:\n    message = f\"Proguard failed ({p.returncode})\"\n    stdout = p.stdout.decode()\n    if stdout:\n      message += f\"\\n  stdout:\\n{stdout}\"\n    stderr = p.stderr.decode()\n    if stderr:\n      message += f\"\\n  stderr:\\n{stderr}\"\n    raise RuntimeError(message)\n\n\ndef reset_timestamps(input_jar, output_jar, timestamp):\n  \"\"\"Rewrite the given jar file to reset all timestamps to a known value.\n\n  Args:\n    input_jar: The jar file to be modified.\n    output_jar: The path to write the destination jar to.\n    timestamp: The known timestamp to modify the output_jar with.\n  \"\"\"\n  # print(\"Resetting timestamps in %s to %s, writing to %s\" % (input,\n  # timestamp, output))\n\n  with zipfile.ZipFile(input_jar, mode=\"r\") as src:\n    with zipfile.ZipFile(output_jar, mode=\"w\") as dest:\n      for info in src.infolist():\n        # print(f\"Filename: {info.filename}\")\n        # print(f\"  Modified: {datetime.datetime(*info.date_time)}\")","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/bazelbuild/bazel/blob/e6e199d0601a244511b4cf18c8b2828aa73db1fd/tools/build_defs/proguard/wrapper.py#L83-L119","documentation":"Raised by the proguard wrapper after running the proguard subprocess with check=False and observing a non-zero exit code. The RuntimeError message embeds p.returncode plus any decoded stdout and stderr, so the underlying proguard diagnostics travel with the exception.","triggerScenarios":"apply_proguard() invoked with source jars, dep jars, or a spec that proguard rejects: missing classes referenced by -keep rules, malformed .pro file syntax, duplicate class files, or incompatible proguard version.","commonSituations":"A -keep class references a class not in the inputs; deps list incomplete so proguard cannot resolve the classpath; spec file contains options unsupported by the shipped proguard version.","solutions":["Read the embedded stderr in the message — proguard's own diagnostics name the exact offending rule or class.","Add the missing jars to the deps argument so proguard can resolve referenced classes.","Fix or remove the offending -keep/-assumenosideeffects entry in the proguard spec.","If version-related, align the proguard spec dialect with the proguard binary shipped in the wrapper's runfiles."],"exampleFix":"# before\napply_proguard(srcs=[\"a.jar\"], deps=[], proguard_spec=\"spec.pro\", ...)\n# spec.pro: -keep class com.example.Missing { *; }\n\n# after\napply_proguard(srcs=[\"a.jar\"], deps=[\"missing.jar\"], proguard_spec=\"spec.pro\", ...)","handlingStrategy":"try-catch","validationCode":"for j in srcs + deps:\n    assert os.path.exists(j), 'missing jar for proguard: %s' % j","typeGuard":null,"tryCatchPattern":"try:\n    apply_proguard(srcs, deps, spec, out)\nexcept RuntimeError as e:\n    # message embeds returncode, stdout, stderr of proguard\n    log_error('proguard failure', details=str(e))\n    raise","preventionTips":["Keep the deps list complete so every -keep-referenced class is resolvable.","Validate the .pro spec against the library allowlist (see proguard_allowlister) before the build runs proguard."],"tags":["proguard","android","subprocess","build"],"backgroundTag":null,"analyzedSha":"e6e199d0601a244511b4cf18c8b2828aa73db1fd","analyzedAt":"2026-08-14T10:24:27.848Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}