Skip to content
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

Custom adapter's annotations with Proguard #93

Closed
rephiscorth opened this issue Sep 30, 2015 · 5 comments
Closed

Custom adapter's annotations with Proguard #93

rephiscorth opened this issue Sep 30, 2015 · 5 comments
Milestone

Comments

@rephiscorth
Copy link

Is there a configuration to make moshi work with Proguard? specifically the @FromJson and ToJson annotation?

I figured if I put this:

-keep class com.squareup.moshi.** { *; }
-keepattributes *Annotation*

it might work but I get Expected at least one @ToJson or @FromJson method on com.example.app.mypackage. Since it works perfectly when proguard is off, I'm guessing my configuration is wrong. Thanks in advance :)

@ytRino
Copy link

ytRino commented Oct 5, 2015

Not tested, but in my experience, you can try -keepclassmembers with your methods.

@tibbi
Copy link

tibbi commented Nov 22, 2015

this seems to work
-keep public class com.example.www.MyAdapter {
*;
}

@ahmedre
Copy link

ahmedre commented Jan 3, 2016

expanding on tibbi's comment, what needs to be kept here are the (application specific) classes that Moshi is going to be serializing/deserializing to JSON.

i.e. if you have a JsonAdapter<Foo>, Foo (and anything referenced by Foo) need to be kept in proguard.

i additionally added:

-keep class com.squareup.moshi.** { *; }
-keep interface com.squareup.moshi.** { *; }
-dontwarn com.squareup.moshi.**

@xuxucode
Copy link
Contributor

xuxucode commented Mar 5, 2016

-keepclassmembers class ** {
    @com.squareup.moshi.FromJson *;
    @com.squareup.moshi.ToJson *;
}

@NightlyNexus
Copy link
Contributor

The ProGuard configuration is documented now. https://github.com/square/moshi#proguard
Feel free to open a new issue or send a PR if something there isn't up to date!

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

No branches or pull requests

7 participants