Skip to content

docs: restore ProGuard setup instructions - #2171

Open
arnabnandy7 wants to merge 2 commits into
googleapis:mainfrom
arnabnandy7:fix/proguard-rules-link
Open

arnabnandy7 wants to merge 2 commits into
googleapis:mainfrom
arnabnandy7:fix/proguard-rules-link

Conversation

@arnabnandy7

Copy link
Copy Markdown

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #2089 ☕️

Summary

Restores the missing ProGuard section in the setup documentation using the existing rules from google-http-client-assembly/proguard-google-http-client.txt.

The documentation also separates the Android-specific warning suppression from the common rules, making the instructions applicable to desktop applications.

Validation

  • git diff --check
  • Documentation-only change; Java tests were not required

@ashughes

Copy link
Copy Markdown

The restored rules appear incomplete for strict R8 full mode: model construction also requires protection for public no-argument constructors.

I reproduced this with google-http-client and google-http-client-gson 2.2.0 using R8 9.4.24. With the rules proposed here, R8 makes a GenericJson response model abstract and removes its constructor. JSON parsing then fails in Types.newInstance() with NoSuchMethodException.

Adding the following rule alongside the existing attribute and annotated-field rules fixes the reproducer’s parsing cases, including typed nested models:

-keepclasseswithmembers,allowobfuscation class * {
    @com.google.api.client.util.Key <fields>;
    public <init>();
}

The existing annotated-field rule should remain: request classes with only parameterized constructors do not match this additional rule, and their JSON field names still need protection.

The 2.2.0 construction code calls Class.newInstance(), which requires a public no-argument constructor. These tests used JVM classfile output; I have not tested an Android APK using 2.2.0.

Could this documentation cover constructor retention too? Bundled consumer rules and an R8 regression test would also help prevent applications from having to discover this requirement independently.

Signed-off-by: Arnab Nandy <arnab_nandy7@yahoo.com>
Signed-off-by: Arnab Nandy <arnab_nandy7@yahoo.com>
@arnabnandy7
arnabnandy7 force-pushed the fix/proguard-rules-link branch from 0d20270 to e924cee Compare October 10, 2026 02:52
@arnabnandy7

Copy link
Copy Markdown
Author

Could this documentation cover constructor retention too? Bundled consumer rules and an R8 regression test would also help prevent applications from having to discover this requirement independently.

@ashughes yes why not, I've updated please review.

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

size: s Pull request size is small.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Broken link to proguard rules

2 participants