Proguard方法优化

Proguard method optimization

使用 Proguard 时,一些方法主体被替换为:

public void someMethod(int paramInt1, int paramInt2, boolean paramBoolean, String paramString){

 // Byte code:
    //   0: aload_1
    //   1: invokeinterface getItemId : ()I
    //   6: istore_2
    //   7: iload_2
    //   8: ldc_w 2131296320
    //   11: if_icmpne -> 31
    //   14: aload_0
    //   15: new android/content/Intent
    //   18: dup
    //   19: aload_0
    //   20: ldc_w com/example/turtle/Activity
    //   23: invokespecial <init> : (Landroid/content/Context;Ljava/lang/Class;)V
    //   26: invokevirtual startActivity : (Landroid/content/Intent;)V
    //   29: iconst_1
    //   30: ireturn
    //   31: iload_2
    //   32: ldc_w 2131296310
    //   35: if_icmpne -> 95
    //   38: aload_0
    //   39: getfield O : Landroid/view/View;
    //   42: ldc_w 'Layout Changed'
    //   ...


}

虽然他们中的大多数人都有这样的东西:

public void anotherMethod(){

    this.W.setColor(i);
    this.X.setTextColor(i);
    this.Y.setColor(i);
    this.Z.setColor(i);
    b.c.a.x0.a a1 = new b.c.a.x0.a();
    a1.setDuration(100);
    a.u.m.a((ViewGroup)this.a0, (a.u.i)a1);
    if (this.U) {
      this.a0.removeView((View)this.h0);
      linearLayout = this.a0;
      a2 = this.g0;
    } else {
      this.a0.removeView((View)this.b0);
      this.a0.removeView((View)this.d0);
      linearLayout = this.a0;
      a2 = this.e0;
    } 

}

为什么他们不像第一个示例代码?有没有办法像第一个示例代码那样强制 Proguard 优化方法?

我用dex2jar反编译jd-gui查看

感谢任何见解...

ProGuard 在这两种方法之间的作用没有区别。

区别在于您用来读取 ProGuard 输出的工具:它可以和不能反编译哪些字节码使其看起来像正常的Java来源。