Retrofit 2 not sending data when ProGuard is enabled

前端 未结 7 1110
抹茶落季
抹茶落季 2020-12-30 00:43

I try to login my users using Retrofit 2. (Basically a GET to the login URL with a basic header) It works well but once I ProGuard it, the Header Authorization is not sent a

相关标签:
7条回答
  • 2020-12-30 01:47

    finally i find. just try this if you use Gson , add this to retrofit pro-guard :

    -keepclassmembers,allowobfuscation class * {
      @com.google.gson.annotations.SerializedName <fields>;
    } 
    

    then use @SerializedName("name") in your model .kotlin example:

    class PaymentRequestModel (
        @SerializedName("name")
        @Expose
        var name : String = "",
    }
    
    0 讨论(0)
提交回复
热议问题