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
Provide consumer Proguard rules for Android #1121
Comments
This can't be done fully on library's side, unfortunately — some proguard rules have to be rewritten using an actual package name of the application |
I had a feeling that might be an impetus, though I wasn't sure whether there was some way to work around that. Maybe adding an annotation to the generated code that Proguard can target? (I'm not very familiar with the inner workings of the library or Proguard, so not sure how feasible it would actually be.) |
One possible solutionMark the gen code with specific annotations and add rules to keep all the classes with annotations |
In fact, android defines |
My rules:
See Also #1129 |
I'm against this proposal as I said in #1129:
|
Perhaps we can use a clever compiler plugin to detect serializer staticly in most cases. |
Hello, I bumped into runtime crashes because the rules are not bundled. @sandwwraith most of the rules don't depend on the package of the models, so all these rules could be bundled, which would make the setup much easier as only app-specific rules would need to live in the end codebase. Even better than that, since @Whathecode edits in #1721, it turns out you'd not need custom proguard/R8 rules at all, unless you have custom named companion objects, which is quite a rare thing AFAIK. See one of the files provided by kotlinx.coroutines for that: Shall I send a PR adding those files? |
Note that the reason they weren't bundled yet is:
But arguably that's enough of an edge case to simply apply the generic rules by default. You should consider the tradeoff with how difficult it potentially is to remove the default bundled rules (I don't know), and possibly document that as well. |
I've looked at current suggested proguard rules, and it seems that most of them don't include an application package indeed. So yes, embedding rules is possible. And of course, I would be happy to see your PR! |
Also pls take a look at this comment: #2050 (comment) |
Is this issue fully resolved now since #2092 has been merged? |
Wait, I think we only need for it to be released. Anything preventing it? |
Android provides a way for libraries to package their own Proguard rules such that users of the library don't need to add rules explicitly. Having consumer rules available simplifies the upgrade process (devs currently need to remember to upgrade the Proguard rules alongside the library version).
The text was updated successfully, but these errors were encountered: