Retrofit 2 not sending data when ProGuard is enabled

前端 未结 7 1158
抹茶落季
抹茶落季 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:28

    You need to add

     @SerializedName("yourInputParameter")
    

    in your bean(model) class for your request body

    For example

     public class YourClass{
           @SerializedName("yourInputParameter") String yourInputParameter;
    
           ...
         }
    

    it will work

    because now retrofit unable to read your request body because proguard(minifyEnabled) is true

    after adding @SerializedName in your request body it will definitely work for you

提交回复
热议问题