【问题标题】:Proguard Change String Request Variable name when send to Server发送到服务器时 Proguard 更改字符串请求变量名称
【发布时间】:2021-02-17 10:56:23
【问题描述】:

我在创建 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 string request 我的班级名称是 (Checkoutinfo) pakege 名称是 com.app.trasfer

【问题讨论】:

    标签: java android proguard


    【解决方案1】:

    通过添加@Keep注释保持用户学生对象在你的班级顶部,如下所示

    @Keep
    class Student{
    int id;
    }
    

    【讨论】:

      【解决方案2】:

      你有两种选择来解决它

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

      字段序列化名称

      @SerializedName("keyType")
      String keyType;
      

      proguard 配置

      -keepclassmembers,allowobfuscation class * {
          @com.google.gson.annotations.SerializedName <fields>;
      }
      -keep,allowobfuscation @interface com.google.gson.annotations.**
      
      1. 如果你不想使用注解,那么你需要从混淆中排除该类

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

      【讨论】:

      • 我不明白,你能不能用第二种方法写我的类和packegename 有问题,我的字符串数组键变量也在请求中
      • -keepclassmembers class com.app.trasfer.Checkoutinfo{ public protected private *; #保留默认成员和函数 !public !protected !private *; }
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-03-21
      • 2017-04-21
      • 2012-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多