How to use AutoValue with Retrofit 2?

前端 未结 2 740
感情败类
感情败类 2021-02-04 11:11

I\'ve got AutoValue (and the android-apt plugin) working in a project, and I\'m aware of Ryan Harter\'s gson extension for AutoValue, but how do I hook Retrofit 2 up to use the

2条回答
  •  孤街浪徒
    2021-02-04 11:18

    Here's a Gist by Jake Wharton for a Gson TypeAdapterFactory that just requires you add an annotation to all of your AutoValue classes that require working with Gson https://gist.github.com/JakeWharton/0d67d01badcee0ae7bc9

    Works great for me.

    Here's some proguard help too..

    -keep class **.AutoValue_*
    -keepnames @yourpackage.AutoGson class *
    

提交回复
热议问题