Skip to content

Add use_minimal_keep_rules flag for aapt2 minimal proguard keep rules#538

Open
Dolfik1 wants to merge 1 commit into
bazelbuild:mainfrom
Dolfik1:use-minimal-keep-rules
Open

Add use_minimal_keep_rules flag for aapt2 minimal proguard keep rules#538
Dolfik1 wants to merge 1 commit into
bazelbuild:mainfrom
Dolfik1:use-minimal-keep-rules

Conversation

@Dolfik1

@Dolfik1 Dolfik1 commented Jul 10, 2026

Copy link
Copy Markdown

Problem

aapt2 generates broad resource keep rules by default. Bazel and Gradle produce different rules for the same target:

# Bazel (current)
-keep class androidx.appcompat.widget.AlertDialogLayout { <init>(...); }

# Gradle
-keep class androidx.appcompat.widget.AlertDialogLayout { <init>(android.content.Context, android.util.AttributeSet); }

Gradle passes --proguard-minimal-keep-rules to aapt2, emitting precise member signatures. Bazel does not, so keep rules (and shrinking output) diverge.

Change

Add opt-in flag use_minimal_keep_rules. When enabled, aapt2 link receives --proguard-minimal-keep-rules, matching Gradle.

Off by default. Enable with:

build --define=use_minimal_keep_rules=true

Mirrors the existing conditionalKeepRules / --proguard-conditional-keep-rules path.

@google-cla

google-cla Bot commented Jul 10, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@Dolfik1 Dolfik1 force-pushed the use-minimal-keep-rules branch from 1dbb9e2 to ab83d1b Compare July 10, 2026 06:21
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 this pull request may close these issues.

1 participant