Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When proguard_specs is not None, optimize fails due to divergent logic around R8 and outputs #343

Open
pswaminathan opened this issue Mar 6, 2025 · 0 comments · May be fixed by #344
Open

Comments

@pswaminathan
Copy link

To reproduce this, add a select or proguard_specs to trigger processing optimizations.

android_binary impl can expect there to be outputs in ctx.outputs:

if ctx.attr._generate_proguard_outputs:
proguard_output_jar = ctx.outputs.proguard_jar
proguard_output_config = ctx.outputs.proguard_config

But these outputs are only declared if not using R8 and _generate_proguard_outputs is True:

# proguard_specs is too valuable an attribute to make it nonconfigurable, so if its value is
# configurable (i.e. of type 'select'), _generate_proguard_outputs will be set to True and the
# predeclared proguard outputs will be generated. If the proguard_specs attribute resolves to an
# empty list eventually, we do not use it in the dexing. If user explicitly tries to request it,
# it will fail.
if not acls.use_r8(label) and _generate_proguard_outputs:
outputs["proguard_jar"] = "%{name}_proguard.jar"
outputs["proguard_config"] = "%{name}_proguard.config"
if proguard_generate_mapping:
outputs["proguard_map"] = "%{name}_proguard.map"
return outputs

Because all ACLs are enabled by default, this means any build with non-None proguard_specs fails with the below:

ERROR: /src/app/main/com/app/BUILD.bazel:230:15: in android_binary rule //src/app/main/com/app:app: 
Traceback (most recent call last):
	File "/private/var/tmp/_bazel_p/38fbac32ce3b415b3947148100343188/external/rules_android~/rules/android_binary/impl.bzl", line 1112, column 35, in impl
		return processing_pipeline.run(ctx, java_package, _PROCESSING_PIPELINE)
	File "/private/var/tmp/_bazel_p/38fbac32ce3b415b3947148100343188/external/rules_android~/rules/processing_pipeline.bzl", line 85, column 23, in _run
		info = execute(ctx, **target_ctx)
	File "/private/var/tmp/_bazel_p/38fbac32ce3b415b3947148100343188/external/rules_android~/rules/android_binary/impl.bzl", line 797, column 42, in _process_optimize
		proguard_output_jar = ctx.outputs.proguard_jar
Error: No attribute 'proguard_jar' in outputs. Make sure you declared a rule output with this name.
pswaminathan added a commit to pswaminathan/rules_android that referenced this issue Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant