Skip to content

fix(android): add R8 keep rules to core - #8658

Open
ItsChaceD wants to merge 3 commits into
nextfrom
fix/RMET-5521/android-r8-core-rules
Open

ItsChaceD wants to merge 3 commits into
nextfrom
fix/RMET-5521/android-r8-core-rules

Conversation

@ItsChaceD

@ItsChaceD ItsChaceD commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds keep rules to core's proguard-rules.pro, which reaches every app through consumerProguardFiles:

Tested on 9.0.0-alpha.8 with R8 on. With the current rules, an @ActivityCallback on a package-private base class is lost. With these rules it matches R8 off.

Change Type

  • Fix
  • Feature
  • Refactor
  • Breaking Change
  • Documentation
  • Other (CI, chores, etc.)

Rationale / Problems Fixed

https://outsystemsrd.atlassian.net/browse/RMET-5521

Platforms Affected

  • Android
  • iOS
  • Web

Notes

The Room and Firebase rules from the first version now ship in the plugins that need them, per review. Capacitor 8 gets the callback rule in #8657.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because some of this conflicts with PRs #8657 #8646, I'm wondering if it's worth instead after merging 8657 merge main to next, and then in this PR we remove the NativePlugin line because that's removed in Cap 9?

Because as of right now the only difference between this PR and the other ones is no NativePlugin right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, the only difference is the NativePlugin line. Once #8657 is in and main is merged into next, I’ll drop that line here or close this PR if it’s already gone.

@jcesarmobile jcesarmobile left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this rules are for Capacitor itself, Capacitor doesn't use firebase, so I don't think we should add rules for things we don't use in Capacitor

For apps it can be added in the template file
https://github.com/ionic-team/capacitor/blob/main/android-template/app/proguard-rules.pro
but also, I don't think it's something we should add for all users if not all of them are using that. And also, if we add rules in the template, OS uses their own templates, so would have no effect on OS apps.

plugins also have a proguard-rules.pro file, I think that's where this should go, even if it means that several plugins add the same rules, but it's the plugins that really need it

@ItsChaceD

Copy link
Copy Markdown
Contributor Author

this rules are for Capacitor itself, Capacitor doesn't use firebase, so I don't think we should add rules for things we don't use in Capacitor

For apps it can be added in the template file https://github.com/ionic-team/capacitor/blob/main/android-template/app/proguard-rules.pro but also, I don't think it's something we should add for all users if not all of them are using that. And also, if we add rules in the template, OS uses their own templates, so would have no effect on OS apps.

plugins also have a proguard-rules.pro file, I think that's where this should go, even if it means that several plugins add the same rules, but it's the plugins that really need it

Yeah that's probably better. I’ll drop the Room and Firebase lines here and from #8657, and leave the template alone. The plugins that bring the old versions (Health & Fitness, Barcode Scanner, and the OS Firebase plugins) will ship the rules themselves. I'll also add a note in the Cap 9 docs which rules apps need if their own dependencies bring them.

@ItsChaceD

Copy link
Copy Markdown
Contributor Author

this rules are for Capacitor itself, Capacitor doesn't use firebase, so I don't think we should add rules for things we don't use in Capacitor

For apps it can be added in the template file https://github.com/ionic-team/capacitor/blob/main/android-template/app/proguard-rules.pro but also, I don't think it's something we should add for all users if not all of them are using that. And also, if we add rules in the template, OS uses their own templates, so would have no effect on OS apps.

plugins also have a proguard-rules.pro file, I think that's where this should go, even if it means that several plugins add the same rules, but it's the plugins that really need it

Dropped the Room and Firebase lines. Health & Fitness, Barcode Scanner and the OS Firebase plugins ship them now, and the docs list them for apps (ionic-team/capacitor-docs#622).

This branch has not been deployed

No deployments
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.

3 participants