Proguard 发送到服务器时更改字符串请求变量名称

Proguard Change String Request Variable name when send to Server

我在创建 Signapk Proguard 时使用字符串请求更改变量名称在 a b c d e f 我如何处理它 这只是一个请求中的一个问题所有其他请求在此请求中工作正常我正在使用 GSON 这是我的代码

senditems_是一个数组列表,其中包含学生的5条记录

String studentBatchListString = new Gson().toJson(send_items_);
@Override
protected Map<String, String> getParams() throws AuthFailureError { 
   Map<String, String> parameters = new HashMap<String, String>(); 
   Log.i("timessendreq","send");                    
   parameters.put("list_items",studentBatchListString);
   return parameters;
}

我正在使用 volley 字符串请求 我的 Class 名字是 (Checkoutinfo) pakege 名称是 com.app.trasfer

你有两种选择来解决它

  1. 使用代码中的注释并添加适当的混淆器配置

字段序列化名称

@SerializedName("keyType")
String keyType;

proguard 配置

-keepclassmembers,allowobfuscation class * {
    @com.google.gson.annotations.SerializedName <fields>;
}
-keep,allowobfuscation @interface com.google.gson.annotations.**
  1. 如果您不想使用注释,则需要将 class 从混淆中排除

    -keepclassmembers class com.example.app.YourClass{
         public protected private *;
         #Keep default members & functions
         !public !protected !private *;
     }
    

通过添加@Keep 注释将用户学生对象保留在您的顶部class,如下所示

@Keep
class Student{
int id;
}