设置ProGuard以模糊局部变量和参数 [英] Setting ProGuard to obfuscate local variables and arguments

查看:696
本文介绍了设置ProGuard以模糊局部变量和参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎找不到混淆局部变量的设置,在一个被混淆的类的方法内部。

I can't seem to find the setting that will obfuscate the local variables, inside methods of a class which is obfuscated.

这是一个摘录来自其中一个我已经反编译的类,有一些明显的缺失部分。理想情况下,方法的参数和局部变量也会被混淆。

Here's an excerpt from one of the classes I've decompiled, with some obvious missing parts. Ideally, the arguments for the methods, and the local variables, would be obfuscated too.

public class eA extends gu
{
  private final gt a;
  private final gt b;

  public static boolean a(fy game)
  {
    boolean playerDead = game.k().j() <= 0;
    boolean enemyDead = game.g().a().size <= 0;
    boolean wavesRemain = game.r() > 0;
    return (playerDead) || ((!wavesRemain) && (enemyDead));
  }

  public eA(gt gameState, gt boardState)
  {
    this.b = gameState;
    this.a = boardState;
  }

  public void a()
  {
    n();
    boolean playerDead = this.f.k().j() <= 0;
    boolean enemyDead = this.f.g().a().size <= 0;
    if (a(this.f)) {
      if (enemyDead) {
        this.f.a(new eG(1));
        this.e.a(new eW());
      } else if (playerDead) {
        this.f.a(new eF());

编辑,我还附上了proguard配置

Edit, I'm also attaching the proguard config

-dontskipnonpubliclibraryclassmembers
-dontshrink
-dontoptimize
-printmapping build/libs/output/obfuscation.map
-keepattributes
-adaptclassstrings
-dontnote
-dontwarn

# Keep Android classes
-keep class ** extends android.** {
    <fields>;
    <methods>;
}

# Keep serializable classes & fields
-keep class ** extends java.io.Serializable {
    <fields>;
}

# Keep - Applications. Keep all application classes, along with their 'main'
# methods.
-keepclasseswithmembers public class * {
    public static void main(java.lang.String[]);
}

# Also keep - Enumerations. Keep the special static methods that are required in
# enumeration classes.
-keepclassmembers enum  * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

# Keep names - Native method names. Keep all native class/method names.
-keepclasseswithmembers,allowshrinking class * {
    native <methods>;
}


推荐答案

你应该删除或改进选项 -keepattributes 。它意味着使用局部变量名保存属性:

You should remove or refine the option -keepattributes. It implies keeping attributes with local variable names:

-keepattributes LocalVariableTable,LocalVariableTypeTable

你至少可以排除那些

-keepattributes !LocalVariableTable,!LocalVariableTypeTable

理想情况下,您只保留严格要求的属性。

Ideally, you'd only preserve the attributes that are strictly required.

请参阅ProGuard手册>用法> -keepattributes

See the ProGuard manual > Usage > -keepattributes

这篇关于设置ProGuard以模糊局部变量和参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆