[英]Abnormal behavior while using proguard
My Original code is : 我的原始代码是:
private String hello;
private int i = 0;
public void test() {
if (i == 0) {
hello = "asdas";
} else {
hello = "asasvfasfas";
}
}
After Obfuscating with proguard : 用proguard混淆之后:
private String a;
private int c = 0;
public void a()
{
if (this.c == 0);
for (this.a = "asdas"; ; this.a = "asasvfasfas")
return;
}
In project properties : 在项目属性中:
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
My proguard-project.txt file is empty, so I guess it should be using the default config file : proguard-android.txt. 我的proguard-project.txt文件是空的,所以我猜它应该使用默认的配置文件:proguard-android.txt。
Why it is behaving like this? 为什么会这样? How can I prevent this kind of code optimization?
如何防止这种代码优化? Please help.
请帮忙。
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";
}
The Proguard just doesn't remove your original but unreachable source lines, just puts them into unreachable places. Proguard只是不删除原始但无法访问的源代码行,只需将它们放入无法访问的位置即可。 It is converting your code into equivalent but not-so human friendly format.
它将您的代码转换为等效但不那么人性化的格式。
So, the generated code works as yours, it is just obfuscated. 因此,生成的代码与您的代码一样,只是混淆了。 If you don't like it, don't use obfuscators.
如果您不喜欢它,请不要使用混淆器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.