Skip to content

Draft: Removes keep rules and adds optimized resource shrinking #198

Draft
AjeshRPai wants to merge 5 commits intomainfrom
keep_rule_changes
Draft

Draft: Removes keep rules and adds optimized resource shrinking #198
AjeshRPai wants to merge 5 commits intomainfrom
keep_rule_changes

Conversation

@AjeshRPai
Copy link
Contributor

@AjeshRPai AjeshRPai commented Feb 18, 2026

This PR fixes #165 by

  1. Removes redundant keep rules
  2. Adds optimized resource shrinking to the codebase

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @AjeshRPai, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on optimizing the application's build size and performance by refining ProGuard/R8 configurations. It streamlines the build process by eliminating unnecessary code retention rules and activating advanced resource shrinking capabilities, leading to a more compact and efficient final application package.

Highlights

  • Redundant Keep Rules Removed: Several -keep rules in proguard-rules.pro files for various libraries (Firebase, Apache, OkHttp, BouncyCastle, etc.) have been removed, indicating that they are no longer necessary or are handled automatically by R8.
  • Optimized Resource Shrinking Enabled: The android.r8.optimizedResourceShrinking=true flag has been added to gradle.properties, enabling more efficient resource shrinking during the build process.
  • Kotlin Intrinsics Optimization: New ProGuard rules have been added to assume no side effects for specific methods within kotlin.jvm.internal.Intrinsics, which can lead to further code optimization by R8.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • app/proguard-rules.pro
    • Removed -keep rules for Firebase, Apache, Jackson, Servlet, IETF JGSS, and OkHttp classes.
    • Added -repackageclasses directive.
    • Added -assumenosideeffects rules for Kotlin Intrinsics methods to allow for more aggressive optimization.
  • gradle.properties
    • Removed android.disableMinifyLocalDependenciesForLibraries=true.
    • Added android.r8.optimizedResourceShrinking=true to enable optimized resource shrinking.
  • watchface/proguard-rules.pro
    • Removed -dontwarn javax.imageio.**.
    • Removed numerous -keep rules for PackPackage, BouncyCastle, APK Signer, Apache Xerces, and various Java XML (JAXP, DOM, SAX) interfaces and classes.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request aims to reduce the application size by removing redundant ProGuard keep rules and enabling optimized resource shrinking. The changes include enabling android.r8.optimizedResourceShrinking, adding R8 optimizations for Kotlin intrinsics, and removing several broad keep rules. While these changes are beneficial for optimization, I've raised a concern about the aggressive removal of keep rules in watchface/proguard-rules.pro. Specifically, removing rules for libraries like BouncyCastle and APK Signer, which are known to use reflection, poses a significant risk of runtime crashes. It's crucial to verify that these rules are genuinely redundant before merging.

I am having trouble creating individual review comments. Click here to see my feedback.

watchface/proguard-rules.pro (11-34)

high

Removing these -keep rules is a high-risk change. Libraries like BouncyCastle, APK Signer, and various XML parsers are often used via reflection, and removing their -keep rules can lead to ClassNotFoundException or other reflection-related crashes at runtime. The comments in the original file for BouncyCastle even explicitly state this. While the goal of removing redundant rules is good, it's critical to ensure these are truly redundant (e.g., because the libraries now ship with their own consumer ProGuard rules). Otherwise, these rules should be restored to prevent potential runtime failures.

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.

Project keep rules should not be needed

1 participant

Comments