而使用ProGuard异常行为 [英] Abnormal behavior while using proguard

查看:184
本文介绍了而使用ProGuard异常行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我原来的code是:

private String hello;
private int i = 0;

public void test() {
    if (i == 0) {
        hello = "asdas";
    } else {
        hello = "asasvfasfas";
    }
}

使用ProGuard模糊处理之后:

After Obfuscating with proguard :

private String a;
private int c = 0;

public void a()
  {
    if (this.c == 0);
    for (this.a = "asdas"; ; this.a = "asasvfasfas")
      return;
  }

在项目属性:

proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

我ProGuard的-project.txt文件是空的,所以我想它应该使用默认的配置文件:proguard的-android.txt

My proguard-project.txt file is empty, so I guess it should be using the default config file : proguard-android.txt.

为什么它是表现这样吗?我怎样才能prevent这种code优化?请帮助。

Why it is behaving like this? How can I prevent this kind of code optimization? Please help.

推荐答案

由于您的code是只有你输入的片段,我想,你的code会被轻易优化成这样:

Because your code is only that fragment you entered, I assume, your code will be easily optimized into this:

private String hello;

public void test() {
        hello = "asdas";
}

ProGuard的只是不删除您原来的,但无法访问源代码行,只需将它们放入碰不到的地方。这是您的转换code到等价的,但不那么人类友好的格式。

The Proguard just doesn't remove your original but unreachable source lines, just puts them into unreachable places. It is converting your code into equivalent but not-so human friendly format.

因此​​,产生code工作是你的,它只是混淆。如果你不喜欢它,请不要使用模糊处理。

So, the generated code works as yours, it is just obfuscated. If you don't like it, don't use obfuscators.

这篇关于而使用ProGuard异常行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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