-
Notifications
You must be signed in to change notification settings - Fork 7.3k
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
ProGuard and Retrofit don't enjoy each other... #117
Comments
Can you try |
Proguard is an advanced, powerful tool. It would be far too hard for us to maintain documentation on all of our libraries for proper usage. We recommend you just keep everything in each library until you are comfortable with tweaking and testing the values yourself. Keeping everything is especially useful in complex libraries like this since we rely heavily on reflection for certain aspects of the configuration which breaks with stripping and obfuscation. |
Thanks Jake, you're right, ProGuard is dangerous. I started this application with the Android Bootstrap initially. Adding Retrofit seems to have required some or all of the following to be added, plus or minus:
I also added a -keep statement for the interface that I used to build my REST interface with Retrofit. All is working now. |
I've step tested my rules for retrofit for maximum proguard usage, i could let work my code as expected with the following rules:
The first line are your interface the second line are your models. This is very minimal to achieve maximum of proguard. It would nice to share experience about this. Thank you for reading. |
A more generic approach is to use
for the service interfaces so that you end up with following:
|
@ralphhm Your approach is quite handy |
@JakeWharton Maybe publish it on the website http://square.github.io/retrofit/ ? |
Not a ProGuard user. Someone can send a PR for it. On Sat, Mar 14, 2015 at 12:21 AM Sebastian Roth notifications@github.com
|
There are still some missing pieces not mentioned above that my team has found out the hard way. This is our take:
You need
You can find answers for specific problems on Stack Overflow once you come across them and have an exception to paste into Google. But this should help to prevent those problems for all the people who find this issue after searching Google with much more generic search term. One other thing to note is that by default Retrofit uses GSON to convert server responses and you need some more Proguard configuration for GSON. But that is covered well on Stack Overflow and by the GSON team (though some of their configuration is not need on Android or do not apply to Android). @JakeWharton I'd love to contribute our configuration to the Retrofit website. Is adding a new section for it between "Download" and "Contributing" all right? If not, it'd be great if you suggested an acceptable place for it. |
@JakeWharton, you said you are
Do you use something else for obfuscating code? |
As @ralphhm wrote, you have to keep web service Models from obfuscation, don't know why Also note this, if you have Modules in your project, you have to write |
Following the suggestions here, when we use proguard with Retrofit (3.6.0) then I can see that the rest APIs paths are still kept readable. Any hint or suggestion on how to be able to make them obfuscated as well? |
You cannot
…On Thu, Jul 6, 2017, 7:09 AM Ale ***@***.***> wrote:
Following the suggestions here, when we use proguard with Retrofit (3.6.0)
then I can see that the rest APIs paths are still kept readable. Any hint
or suggestion on how to be able to make them obfuscated as well?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#117 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEEESFkSOoUNilOU30VKhhP7LdRrTmZks5sLMBVgaJpZM4AToWu>
.
|
I think some documentation on proper proguard configuration for Retrofit would be great. Any idea what lines I would put into progaurd.cfg to avoid the following errors:
The text was updated successfully, but these errors were encountered: