-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Remove outdated android-proguard-example #2843
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
Remove outdated android-proguard-example #2843
Conversation
Troubleshooting.md
Outdated
@@ -393,3 +396,11 @@ For backward compatibility it is possible to restore Gson's old behavior of allo | |||
|
|||
- This does not solve any of the type-safety problems mentioned above; in the long term you should prefer one of the other solutions listed above. This system property might be removed in future Gson versions. | |||
- You should only ever set the property to `"true"`, but never to any other value or manually clear it. Otherwise this might counteract any libraries you are using which might have deliberately set the system property because they rely on its behavior. | |||
|
|||
## R8 / ProGuard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't apply ## <a id="r8-proguard"></a> R8 / ProGuard
for this header like the others, as the index of it (#a-idr8-proguarda-r8--proguard
) can't be honored correctly by GitHub web.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that specific to this header? Because for the others GitHub UI seems to ignore the <a>
when deriving the default anchor name (or it only seems to prepend a -
).
If possible I think a stable anchor with <a>
would be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems all existing ones are invalid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ref id works in IDEA's markdown render but GitHub website.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That rather looks like an issue with IntelliJ. In GitHub both anchors work:
- GitHub derived one (also used for the "🔗" icon next to the title):
#-proguard--r8
- The one assigned with
<a>
(which should be referred to within the guide)
#proguard-r8
(though maybe for GitHub this also relies on implementation details to some extent)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to keep the header without id, it works for both IDEA and GitHub. But I can update the style if you want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IntelliJ (IntelliJ IDEA 2024.3.5) seems to be a bit inconsistent. Code completion for Markdown links suggests these #a-idr8-proguarda-r8--proguard
anchors you mentioned. However, for the Markdown preview the custom <a>
anchor links seem to work fine within the same document. But they do not work between different files, e.g. the link from the README to the Troubleshooting guide section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the same behavior as IDEA 2025.1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for this! I have added some small comments.
Maybe the R8 / ProGuard section needs to be expanded:
- it should only say "no additional ProGuard configuration is needed"
- because the Java code of the users needs to adhere to a specific pattern (see below)
- and only "in most cases", there are some corner cases (example)
- it should document requirements for user classes
- classes must have a no-args constructor, and must be either top-level or
static
(to avoid additional implicit constructor args) - fields must be annotated with
@SerializedName
- classes must have a no-args constructor, and must be either top-level or
- maybe it should mention that ProGuard for non-Android projects has to configure the
gson.pro
file manually, seeMETA-INF/proguard/*.pro
files only recognized by Android plugin Guardsquare/proguard#337
If you want I can do that in a follow-up pull request instead though.
Troubleshooting.md
Outdated
@@ -393,3 +396,11 @@ For backward compatibility it is possible to restore Gson's old behavior of allo | |||
|
|||
- This does not solve any of the type-safety problems mentioned above; in the long term you should prefer one of the other solutions listed above. This system property might be removed in future Gson versions. | |||
- You should only ever set the property to `"true"`, but never to any other value or manually clear it. Otherwise this might counteract any libraries you are using which might have deliberately set the system property because they rely on its behavior. | |||
|
|||
## R8 / ProGuard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that specific to this header? Because for the others GitHub UI seems to ignore the <a>
when deriving the default anchor name (or it only seems to prepend a -
).
If possible I think a stable anchor with <a>
would be better.
README.md
Outdated
@@ -68,6 +68,10 @@ see [`GsonBuilder.disableJdkUnsafe()`](https://javadoc.io/doc/com.google.code.gs | |||
|
|||
Older Gson versions may also support lower API levels, however this has not been verified. | |||
|
|||
### R8 / ProGuard | |||
|
|||
See the details in the related section in [Troubleshooting guide](Troubleshooting.md#r8--proguard). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the details in the related section in [Troubleshooting guide](Troubleshooting.md#r8--proguard). | |
See the details in the related section in the [Troubleshooting guide](Troubleshooting.md#r8--proguard). |
Maybe it would also be better to remove this (but still as dedicated "R8 / ProGuard" section) below the "Documentation" section, since it is more specific documentation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I document the R8 / ProGuard section explicitly as I want to warn users like https://github.com/square/retrofit?tab=readme-ov-file#r8--proguard and OkHttp did.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that is fine and a good thing. I was just wondering whether it would be better to have the (existing) "Documentation" section first in the README:
...
Documentation
- API Javadoc: Documentation for the current release
- ...
ProGuard / R8
See the details in the related ...
Because this is a more specific aspect of the documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reasonable! 495aa1b
@@ -67,15 +68,17 @@ Or in case this occurs for a field in one of your classes which you did not actu | |||
|
|||
**Reason:** You probably have not configured ProGuard / R8 correctly | |||
|
|||
**Solution:** Make sure you have configured ProGuard / R8 correctly to preserve the names of your fields. See the [Android example](examples/android-proguard-example/README.md) for more information. | |||
**Solution:** Make sure you have configured ProGuard / R8 correctly to preserve the names of your fields. | |||
See the section below, it's related to this issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Directly link to the section as well?
See the section below, it's related to this issue. | |
See the [ProGuard / R8](#r8--proguard) section for more information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is intended. As I see it, the "random property names" and "field names are being obfuscated" are the same issue; I just wanted to link them together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably should merge these 2 sections.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would keep them separate for now. The symptoms are different (but similar) and if I recall correctly users had experienced and asked about both problems already in the past.
Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
a631002
to
31a02bd
Compare
This point looks unrelated to this PR.
Yeah, I see this point has been noted times like Line 83 in a656395
Line 282 in a656395
Actually, users can keep full the classes as instead, it's not fields must be. Good to know this! We can note it. And may invert all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes, looks good to me. I might do some small follow-up changes, but thanks for taking up this task in the first place!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this!
Purpose
Closes #2718.
Checklist
This is automatically checked by
mvn verify
, but can also be checked on its own usingmvn spotless:check
.Style violations can be fixed using
mvn spotless:apply
; this can be done in a separate commit to verify that it did not cause undesired changes.null
@since $next-version$
(
$next-version$
is a special placeholder which is automatically replaced during release)TestCase
)mvn clean verify javadoc:jar
passes without errors